vision 0.0.1.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +5 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/images/vision/sort-arrows-down.png +0 -0
  5. data/app/assets/images/vision/sort-arrows-up.png +0 -0
  6. data/app/assets/javascripts/redactor-rails/config.js +16 -0
  7. data/app/assets/javascripts/redactor-rails/ru.js +69 -0
  8. data/app/assets/javascripts/vision/application.js +18 -0
  9. data/app/assets/stylesheets/vision/admin.css.less +0 -0
  10. data/app/assets/stylesheets/vision/application.css +24 -0
  11. data/app/assets/stylesheets/vision/bootstrap_and_overrides.css.less +63 -0
  12. data/app/assets/stylesheets/vision/bootstrap_theme/bootstrap-responsive.min.css.less +9 -0
  13. data/app/assets/stylesheets/vision/bootstrap_theme/bootstrap.css.less +5616 -0
  14. data/app/assets/stylesheets/vision/bootstrap_theme/bootswatch.css.less +412 -0
  15. data/app/assets/stylesheets/vision/bootstrap_theme/variables.less +301 -0
  16. data/app/controllers/redactor_rails/pictures_controller.rb +22 -0
  17. data/app/controllers/vision/application_controller.rb +9 -0
  18. data/app/controllers/vision/resource_controller.rb +57 -0
  19. data/app/controllers/vision/responder.rb +4 -0
  20. data/app/helpers/vision/application_helper.rb +42 -0
  21. data/app/helpers/vision/application_helper.rb~ +8 -0
  22. data/app/helpers/vision/resource_helper.rb +10 -0
  23. data/app/helpers/vision/resource_helper.rb~ +10 -0
  24. data/app/models/ability.rb +7 -0
  25. data/app/models/redactor_rails/asset.rb +6 -0
  26. data/app/models/redactor_rails/picture.rb +7 -0
  27. data/app/uploaders/redactor_rails_picture_uploader.rb +53 -0
  28. data/app/views/layouts/vision/application.html.haml +25 -0
  29. data/app/views/shared/_pagination.html.haml +2 -0
  30. data/app/views/vision/application/_user_bar.html.haml +8 -0
  31. data/app/views/vision/resource/_form.html.haml +6 -0
  32. data/app/views/vision/resource/_index.html.haml +16 -0
  33. data/app/views/vision/resource/_search.html.haml +4 -0
  34. data/app/views/vision/resource/edit.html.haml +9 -0
  35. data/app/views/vision/resource/index.html.haml +9 -0
  36. data/app/views/vision/resource/new.html.haml +5 -0
  37. data/app/views/vision/resource/show.html.haml +10 -0
  38. data/config/initializers/simple_form.rb +142 -0
  39. data/config/initializers/simple_form_bootstrap.rb +45 -0
  40. data/config/routes.rb +3 -0
  41. data/lib/generators/install_generator.rb~ +7 -0
  42. data/lib/generators/templates/resource/_form.html.haml +6 -0
  43. data/lib/generators/templates/resource/_index.html.haml +16 -0
  44. data/lib/generators/templates/resource/_search.html.haml +4 -0
  45. data/lib/generators/templates/resource/edit.html.haml +9 -0
  46. data/lib/generators/templates/resource/index.html.haml +9 -0
  47. data/lib/generators/templates/resource/new.html.haml +5 -0
  48. data/lib/generators/templates/resource/show.html.haml +10 -0
  49. data/lib/generators/templates/resource_controller.rb.erb +12 -0
  50. data/lib/generators/templates/vision.rb +2 -0
  51. data/lib/generators/templates/vision_navigation.rb +13 -0
  52. data/lib/generators/vision/install_generator.rb +21 -0
  53. data/lib/generators/vision/install_generator.rb~ +6 -0
  54. data/lib/generators/vision/resource_generator.rb +22 -0
  55. data/lib/generators/vision/views_generator.rb +12 -0
  56. data/lib/tasks/vision_tasks.rake +4 -0
  57. data/lib/vision.rb +33 -0
  58. data/lib/vision/engine.rb +4 -0
  59. data/lib/vision/engine.rb~ +5 -0
  60. data/lib/vision/version.rb +3 -0
  61. data/test/dummy/README.rdoc +261 -0
  62. data/test/dummy/Rakefile +7 -0
  63. data/test/dummy/app/assets/javascripts/application.js +15 -0
  64. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  65. data/test/dummy/app/controllers/application_controller.rb +3 -0
  66. data/test/dummy/app/controllers/vision/users_controller.rb +12 -0
  67. data/test/dummy/app/helpers/application_helper.rb +2 -0
  68. data/test/dummy/app/models/user.rb +11 -0
  69. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  70. data/test/dummy/config.ru +4 -0
  71. data/test/dummy/config/application.rb +59 -0
  72. data/test/dummy/config/boot.rb +10 -0
  73. data/test/dummy/config/database.yml +25 -0
  74. data/test/dummy/config/environment.rb +5 -0
  75. data/test/dummy/config/environments/development.rb +37 -0
  76. data/test/dummy/config/environments/production.rb +67 -0
  77. data/test/dummy/config/environments/test.rb +37 -0
  78. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  79. data/test/dummy/config/initializers/devise.rb +240 -0
  80. data/test/dummy/config/initializers/inflections.rb +15 -0
  81. data/test/dummy/config/initializers/mime_types.rb +5 -0
  82. data/test/dummy/config/initializers/secret_token.rb +7 -0
  83. data/test/dummy/config/initializers/session_store.rb +8 -0
  84. data/test/dummy/config/initializers/vision.rb +2 -0
  85. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  86. data/test/dummy/config/locales/devise.en.yml +59 -0
  87. data/test/dummy/config/locales/en.yml +5 -0
  88. data/test/dummy/config/routes.rb +66 -0
  89. data/test/dummy/config/vision_navigation.rb +13 -0
  90. data/test/dummy/db/development.sqlite3 +0 -0
  91. data/test/dummy/db/migrate/20130211073237_devise_create_users.rb +46 -0
  92. data/test/dummy/db/schema.rb +34 -0
  93. data/test/dummy/db/test.sqlite3 +0 -0
  94. data/test/dummy/log/development.log +1544 -0
  95. data/test/dummy/public/404.html +26 -0
  96. data/test/dummy/public/422.html +26 -0
  97. data/test/dummy/public/500.html +25 -0
  98. data/test/dummy/public/favicon.ico +0 -0
  99. data/test/dummy/script/rails +6 -0
  100. data/test/dummy/test/fixtures/users.yml +11 -0
  101. data/test/dummy/test/unit/user_test.rb +7 -0
  102. data/test/dummy/tmp/cache/assets/BFD/BE0/sprockets%2F7750d34d5ab84713536684084175b777 +0 -0
  103. data/test/dummy/tmp/cache/assets/C0D/930/sprockets%2F57ada54e11211525881db12657063262 +0 -0
  104. data/test/dummy/tmp/cache/assets/C22/760/sprockets%2F01391319c77618e63259d5172da3c087 +0 -0
  105. data/test/dummy/tmp/cache/assets/C61/E30/sprockets%2F7cc7480787c36cb33f8958a018908621 +0 -0
  106. data/test/dummy/tmp/cache/assets/C64/2A0/sprockets%2F134c13b9bd41169120f00f41d229a058 +0 -0
  107. data/test/dummy/tmp/cache/assets/C83/BE0/sprockets%2F07d225b2971966fcc599b7001056e44d +0 -0
  108. data/test/dummy/tmp/cache/assets/CAB/EE0/sprockets%2F93064e70efa31924ce83d518222ba718 +0 -0
  109. data/test/dummy/tmp/cache/assets/CB8/880/sprockets%2F870390941fc4f61d24bc06c257f58a78 +0 -0
  110. data/test/dummy/tmp/cache/assets/CC5/DB0/sprockets%2F185b16e33c6e5952c63fe56e65d80787 +0 -0
  111. data/test/dummy/tmp/cache/assets/CCF/C50/sprockets%2F235f6e18294ffe4e969e1852c84f0893 +0 -0
  112. data/test/dummy/tmp/cache/assets/CD1/B10/sprockets%2F26e034c4229e35b5280e372090ca7acf +0 -0
  113. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  114. data/test/dummy/tmp/cache/assets/CDE/F80/sprockets%2Fab0f6cb3198d15258990f645d46b161a +0 -0
  115. data/test/dummy/tmp/cache/assets/CE0/200/sprockets%2Fa9c2101de170df66d9c80861d89042d6 +0 -0
  116. data/test/dummy/tmp/cache/assets/CE3/4D0/sprockets%2F6381f9fd192014c42dfc274e83c9a650 +0 -0
  117. data/test/dummy/tmp/cache/assets/CEA/6B0/sprockets%2F575d96d2842a1d2deec19fe881033089 +0 -0
  118. data/test/dummy/tmp/cache/assets/CEE/180/sprockets%2Fc5ce9c764b20d7176d70584d76a764e4 +0 -0
  119. data/test/dummy/tmp/cache/assets/CF2/540/sprockets%2F5c1c7a9d6a79855f609fae58f5505513 +0 -0
  120. data/test/dummy/tmp/cache/assets/CF9/8B0/sprockets%2F6580899d8cc41372d92d8a5e8ab78c73 +0 -0
  121. data/test/dummy/tmp/cache/assets/CFB/640/sprockets%2F2a4d6aba04a724d2792087832bd3a0b8 +0 -0
  122. data/test/dummy/tmp/cache/assets/D01/870/sprockets%2F975c929398c5770978a8eb96aac660af +0 -0
  123. data/test/dummy/tmp/cache/assets/D02/B10/sprockets%2F33f4d4d4552a4ae5b172b26c0716c39d +0 -0
  124. data/test/dummy/tmp/cache/assets/D08/980/sprockets%2Fb70493dfb381aae06c270b4965b451f6 +0 -0
  125. data/test/dummy/tmp/cache/assets/D08/9E0/sprockets%2Fbd1b5d382eb7585ef2311f0e8a144185 +0 -0
  126. data/test/dummy/tmp/cache/assets/D12/C80/sprockets%2F6ad24bf08272a07cdd957e174b964b73 +0 -0
  127. data/test/dummy/tmp/cache/assets/D1B/3E0/sprockets%2F77c391e536f4b5060992b74d7fbebc09 +0 -0
  128. data/test/dummy/tmp/cache/assets/D1E/250/sprockets%2Ff976c60140c7662f9d86d9b3048c5dda +0 -0
  129. data/test/dummy/tmp/cache/assets/D21/D90/sprockets%2F976738f91218aa8bfc0e679cf3f3f061 +0 -0
  130. data/test/dummy/tmp/cache/assets/D26/3A0/sprockets%2F89ad96fb04e98d506546aed21b918d79 +0 -0
  131. data/test/dummy/tmp/cache/assets/D30/9A0/sprockets%2F7f9ae14760822ff7b8978a67d6fe36e4 +0 -0
  132. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  133. data/test/dummy/tmp/cache/assets/D3B/5C0/sprockets%2F40ae394bdc18dce154393aed80a27576 +0 -0
  134. data/test/dummy/tmp/cache/assets/D3F/5B0/sprockets%2F6557d14727823bddeba2822eb4fcc951 +0 -0
  135. data/test/dummy/tmp/cache/assets/D45/5A0/sprockets%2Fed747866979a368aef7d8fee884b2789 +0 -0
  136. data/test/dummy/tmp/cache/assets/D4A/880/sprockets%2Fcc23ed71c73788a938e1357d11ca78ef +0 -0
  137. data/test/dummy/tmp/cache/assets/D4D/EF0/sprockets%2F05a24a46916881e9d38ee2e0c8d9f5fb +0 -0
  138. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  139. data/test/dummy/tmp/cache/assets/D50/730/sprockets%2F084ff5f6ea3f368a543911339e9dfe2e +0 -0
  140. data/test/dummy/tmp/cache/assets/D55/740/sprockets%2F6bfb0414e9f0de2e909917674dbe9f95 +0 -0
  141. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  142. data/test/dummy/tmp/cache/assets/D60/8A0/sprockets%2F1aaf8a80a707722d04cd8e53a971b1be +0 -0
  143. data/test/dummy/tmp/cache/assets/D69/DB0/sprockets%2F217c932a66b36e34ed25ced07f9e0be0 +0 -0
  144. data/test/dummy/tmp/cache/assets/D71/370/sprockets%2F19dac330438dea0771e8395b86eddf1c +0 -0
  145. data/test/dummy/tmp/cache/assets/D94/4C0/sprockets%2Fabaa1497cede72926b760ddef110144f +0 -0
  146. data/test/dummy/tmp/cache/assets/DA0/280/sprockets%2Fe2a91fe4ce8ef0c54b515145f44dde82 +0 -0
  147. data/test/dummy/tmp/cache/assets/DA8/F80/sprockets%2F97cf03aa7e0ff76969bab9206da267cd +0 -0
  148. data/test/dummy/tmp/cache/assets/DAC/2F0/sprockets%2Fc630da1a0c4bb5a2529e034ba2c7cdb6 +0 -0
  149. data/test/dummy/tmp/cache/assets/DB3/3A0/sprockets%2F6fce069886bdd665c59c2455edf01efd +0 -0
  150. data/test/dummy/tmp/cache/assets/DBB/030/sprockets%2F3ad40a6ab1a1bd6a4b0efee48168c367 +0 -0
  151. data/test/dummy/tmp/cache/assets/DBC/510/sprockets%2Fc49b6ed55fefd850e586e0f77ac958a7 +0 -0
  152. data/test/dummy/tmp/cache/assets/DCF/000/sprockets%2Fd0dfcf6a2f21043e23cf879aa9b81d9e +0 -0
  153. data/test/dummy/tmp/cache/assets/DCF/EE0/sprockets%2Fb4b66c49e5d32ce05fff1ff1397a50db +0 -0
  154. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  155. data/test/dummy/tmp/cache/assets/DE1/6C0/sprockets%2F6cd864830694d6acbef4f69cd0c88dae +0 -0
  156. data/test/dummy/tmp/cache/assets/DEE/430/sprockets%2Fdfcd51eae6f3a2a51c058c27ee0d750a +0 -0
  157. data/test/dummy/tmp/cache/assets/E02/F00/sprockets%2Fa5845e8c36cf9e160fccfadf0a2db837 +0 -0
  158. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  159. data/test/dummy/tmp/cache/assets/E09/6D0/sprockets%2Fcbdb4fef8b144c0fd37dc8ad96926e64 +0 -0
  160. data/test/dummy/tmp/cache/assets/E0A/210/sprockets%2F05aadb4dc0b849fe9c3dd7788f28c5eb +0 -0
  161. data/test/dummy/tmp/cache/assets/E17/BC0/sprockets%2Ff206319de0be2dd9adcaaa314ecf132f +0 -0
  162. data/test/dummy/tmp/cache/assets/E1A/BD0/sprockets%2F5baeff0d2da03cd0e93a561e71b5aac9 +0 -0
  163. data/test/dummy/tmp/cache/assets/E2D/070/sprockets%2Fc4744f83de73cd2bbd645dabffd16b4c +0 -0
  164. data/test/dummy/tmp/cache/assets/E30/850/sprockets%2Fb6e723da1e4c9dab751ccd5ec295a9fe +0 -0
  165. data/test/integration/navigation_test.rb +10 -0
  166. data/test/test_helper.rb +15 -0
  167. data/test/vision_test.rb +7 -0
  168. metadata +658 -0
@@ -0,0 +1,22 @@
1
+ class RedactorRails::PicturesController < ApplicationController
2
+ before_filter :authenticate_user!
3
+
4
+ def index
5
+ @pictures = RedactorRails.picture_model.find_all({:user_id=>current_user.id})
6
+ render :json => @pictures.to_json
7
+
8
+ end
9
+ def create
10
+ @picture =current_user.redactor_rails_pictures.build # RedactorRails::Picture.new
11
+
12
+ file = params[:file]
13
+ @picture.data = RedactorRails::Http.normalize_param(file, request)
14
+
15
+ if @picture.save
16
+ render :text => { :filelink => @picture.url }.to_json
17
+ else
18
+ render :nothing => true
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,9 @@
1
+ class Vision::ApplicationController < ApplicationController
2
+ protect_from_forgery
3
+
4
+ rescue_from CanCan::AccessDenied do |exception|
5
+ redirect_to admin_root_url, :alert => exception.message
6
+ end
7
+
8
+ before_filter :authenticate_user!
9
+ end
@@ -0,0 +1,57 @@
1
+ class Vision::ResourceController < Vision::ApplicationController
2
+ inherit_resources
3
+ load_and_authorize_resource
4
+
5
+ respond_to :html
6
+ has_scope :page, default:1
7
+ self.responder = Vision::Responder
8
+
9
+ helper_method :attributes, :form_attributes, :sort_column, :sort_direction, :association_attributes, :associations, :searchable?
10
+
11
+ private
12
+
13
+ def collection
14
+ if searchable?
15
+ super.search(params[:q]).order(sort_column + " " + sort_direction)
16
+ else
17
+ super.order(sort_column + " " + sort_direction)
18
+ end
19
+ end
20
+
21
+ def sort_column
22
+ resource_class.column_names.include?(params[:sort]) ? params[:sort] : "updated_at"
23
+ end
24
+
25
+ def sort_direction
26
+ %w[asc desc].include?(params[:direction]) ? params[:direction] : "desc"
27
+ end
28
+
29
+ def attributes
30
+ resource_class.attribute_names - %w(id created_at updated_at)
31
+ end
32
+
33
+ def form_attributes
34
+ attributes
35
+ end
36
+
37
+ def association_attributes
38
+ associations(:belongs_to).map{|a| a.options[:foreign_key] || "#{a.name}_id"}
39
+ end
40
+
41
+ def associations(macro=nil)
42
+ assoc=resource_class.reflect_on_all_associations
43
+ assoc.select!{|a| a.macro==macro.to_sym} unless macro.blank?
44
+ assoc
45
+ end
46
+
47
+ def searchable?
48
+ resource_class.respond_to? :searchable
49
+ end
50
+
51
+ def read_written_by
52
+ can? :read
53
+ end
54
+
55
+
56
+
57
+ end
@@ -0,0 +1,4 @@
1
+ class Vision::Responder < ActionController::Responder
2
+ include Responders::FlashResponder
3
+ include Responders::HttpCacheResponder
4
+ end
@@ -0,0 +1,42 @@
1
+ #coding:utf-8
2
+ module Vision::ApplicationHelper
3
+ ## метод для button_to с bootstrap icon внутри
4
+ #
5
+ # пример (текст из локали, класс иконки, опции кнопки)
6
+ #
7
+ # <%= icon_button_to( t(".save"), "icon-ok-sign",{url_for} {type: 'submit', class: "btn-large btn-success aligned")} %>
8
+ def icon_button_to_tag(text,icon_type=" ", options={})
9
+ button_tag(options) do
10
+ content_tag( :i, " " ,:class=>icon_type)+" "+text
11
+ end
12
+ end
13
+
14
+
15
+ ## метод для button_tag с bootstrap icon внутри
16
+ #
17
+ # пример (текст из локали, класс иконки, опции кнопки)
18
+ #
19
+ # <%= icon_button_tag( t(".save"), "icon-ok-sign", type: 'submit', class: "btn-large btn-success aligned") %>
20
+ def icon_button_tag(text,icon_type=" ", *options)
21
+ button_tag(*options) do
22
+ content_tag( :i, " " ,:class=>icon_type)+" "+text
23
+ end
24
+ end
25
+
26
+ ## метод для link_to с bootstrap icon внутри
27
+ #
28
+ # пример (текст из локали, класс иконки, опции ссылки)
29
+ #
30
+ # <%= icon_link_to(t("layouts.top_menu.logout"), "icon-eject", destroy_user_session_path, :method =>:delete) %>
31
+ def icon_link_to(text,icon_type=" ", *options)
32
+ link_to(*options) do
33
+ content_tag( :i, " " ,:class=>icon_type)+" "+text
34
+ end
35
+ end
36
+
37
+
38
+ def user_name
39
+ current_user.try(:email) || current_user.id
40
+ end
41
+
42
+ end
@@ -0,0 +1,8 @@
1
+ #coding:utf-8
2
+ module Vision::ApplicationHelper
3
+
4
+ def user_name
5
+ current_user.try(:email) || current_user.id
6
+ end
7
+
8
+ end
@@ -0,0 +1,10 @@
1
+ module Vision::ResourceHelper
2
+ def sortable(column, title = nil)
3
+ title ||= resource_class.human_attribute_name(attr)
4
+ css_class = column == sort_column ? "current #{sort_direction}" : nil
5
+ direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
6
+ link_to title, params.merge(:sort => column, :direction => direction, :page=>nil), {:class => css_class}
7
+ end
8
+
9
+
10
+ end
@@ -0,0 +1,10 @@
1
+ module Admin::ResourceHelper
2
+ def sortable(column, title = nil)
3
+ title ||= resource_class.human_attribute_name(attr)
4
+ css_class = column == sort_column ? "current #{sort_direction}" : nil
5
+ direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
6
+ link_to title, params.merge(:sort => column, :direction => direction, :page=>nil), {:class => css_class}
7
+ end
8
+
9
+
10
+ end
@@ -0,0 +1,7 @@
1
+ class Ability
2
+ include CanCan::Ability
3
+
4
+ def initialize(user)
5
+ can :manage, :all
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ class RedactorRails::Asset < ActiveRecord::Base
2
+ include RedactorRails::Orm::ActiveRecord::AssetBase
3
+ delegate :url, :current_path, :size, :content_type, :filename, :to => :data
4
+ validates_presence_of :data
5
+ belongs_to :user
6
+ end
@@ -0,0 +1,7 @@
1
+ class RedactorRails::Picture < RedactorRails::Asset
2
+ mount_uploader :data, RedactorRailsPictureUploader, :mount_on => :data_file_name
3
+
4
+ def url_content
5
+ url(:content)
6
+ end
7
+ end
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+ class RedactorRailsPictureUploader < CarrierWave::Uploader::Base
3
+ include RedactorRails::Backend::CarrierWave
4
+
5
+ # Include RMagick or ImageScience support:
6
+ # include CarrierWave::RMagick
7
+ include CarrierWave::MiniMagick
8
+ # include CarrierWave::ImageScience
9
+
10
+ # Choose what kind of storage to use for this uploader:
11
+ storage :file
12
+
13
+ # Override the directory where uploaded files will be stored.
14
+ # This is a sensible default for uploaders that are meant to be mounted:
15
+ def store_dir
16
+ "system/redactor_assets/pictures/#{model.user.id}/#{model.id}"
17
+ end
18
+
19
+ # Provide a default URL as a default if there hasn't been a file uploaded:
20
+ #def default_url
21
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
22
+ #end
23
+
24
+ # Process files as they are uploaded:
25
+ # process :scale => [200, 300]
26
+ #
27
+ # def scale(width, height)
28
+ # # do something
29
+ # end
30
+
31
+ process :read_dimensions
32
+
33
+ # Create different versions of your uploaded files:
34
+ version :thumb do
35
+ process :resize_to_fill => [118, 100]
36
+ end
37
+
38
+ version :content do
39
+ process :resize_to_limit => [800, 800]
40
+ end
41
+
42
+ # Add a white list of extensions which are allowed to be uploaded.
43
+ # For images you might use something like this:
44
+ def extension_white_list
45
+ RedactorRails.image_file_types
46
+ end
47
+
48
+ # Override the filename of the uploaded files:
49
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
50
+ # def filename
51
+ # "something.jpg" if original_filename
52
+ # end
53
+ end
@@ -0,0 +1,25 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title= Vision.title
5
+ = stylesheet_link_tag "vision/application", :media => "all"
6
+ = javascript_include_tag "vision/application"
7
+ = csrf_meta_tags
8
+ %body
9
+ .navbar.navbar-fixed-top
10
+ .navbar-inner
11
+ .container-fluid
12
+ = link_to Vision.title, vision_root_path, class: 'brand'
13
+ .nav
14
+ = render 'user_bar'
15
+ .container-fluid
16
+ .row-fluid.alerts
17
+ = bootstrap_flash
18
+ .row-fluid
19
+ .span2.bs-docs-sidebar
20
+ = render_navigation :context=>:vision, :expand_all=>true
21
+ .span10
22
+ = yield
23
+ = redactor_lang("ru")
24
+
25
+
@@ -0,0 +1,2 @@
1
+ .row
2
+ = paginate collection, :theme => 'twitter-bootstrap'
@@ -0,0 +1,8 @@
1
+ - if user_signed_in?
2
+ %ul.nav.pull-right
3
+ %li= link_to t('.dashboard'), vision_root_path
4
+ %li= link_to user_name, edit_user_registration_path
5
+ %li= icon_link_to(t('sign_out'), "icon-eject", destroy_user_session_path, :method =>:delete)
6
+ - else
7
+ %ul.nav.pull-right
8
+ %li= link_to (t 'sign_in'), new_user_session_path
@@ -0,0 +1,6 @@
1
+ = simple_form_for [:vision, resource], :html=>{:class=>"form form-horizontal"} do |f|
2
+ - (form_attributes-association_attributes).each do |attr|
3
+ = f.input attr.to_sym, :input_html=>{:class=>"input-xxlarge"}
4
+ - associations(:belongs_to).each do |assoc|
5
+ = f.association assoc.name.to_sym
6
+ = f.submit :class=>"btn btn-success"
@@ -0,0 +1,16 @@
1
+ %table.table.table-striped
2
+ %thead
3
+ %tr
4
+ - attributes.each do |attr|
5
+ %th= sortable attr, resource_class.human_attribute_name(attr)
6
+ %tbody
7
+ - collection.each do |resource|
8
+ %tr
9
+ - attributes.each do |attr|
10
+ %td
11
+ = resource.public_send(attr).to_s.truncate(20)
12
+ %td
13
+ .btn-group
14
+ = link_to t(:show), resource_path(resource), :class=>"btn btn-action"
15
+ = link_to t(:edit), edit_resource_path(resource),:class=>"btn btn-warning"
16
+ = link_to( t(:delete), resource_path(resource),:method => :delete, :confirm =>"This action is irreversible!",:class=>"btn btn-danger" )
@@ -0,0 +1,4 @@
1
+ = form_tag collection_path, :method => 'get', :id => "text_search", :html=>{:class=>"form-search"} do
2
+ = text_field_tag :q, params[:q], :class=>"input-xxlarge search-query"
3
+ = hidden_field_tag :direction, params[:direction]
4
+ = hidden_field_tag :sort, params[:sort]
@@ -0,0 +1,9 @@
1
+ %h2
2
+ = "Edit #{resource_class.model_name.human}"
3
+ .from
4
+ = render "form"
5
+ %br/
6
+ .btn-group
7
+ = link_to t(:show), resource_path(resource), :class=>"btn btn-action"
8
+ = link_to t(:back), collection_path, :class=>"btn btn-warning"
9
+
@@ -0,0 +1,9 @@
1
+ .row
2
+ .span1
3
+ = link_to t(:new), new_resource_path, class: "btn btn-success"
4
+ .span9
5
+ = render :partial => "search" if searchable?
6
+ .row
7
+ = render :partial => "index"
8
+ .row
9
+ = paginate collection, :theme => 'twitter-bootstrap'
@@ -0,0 +1,5 @@
1
+ %h2
2
+ = "New #{resource_class.model_name.human}"
3
+ = render :partial => "form"
4
+ %br/
5
+ = link_to t(:back), collection_path
@@ -0,0 +1,10 @@
1
+ %div
2
+ %dl.dl-horizontal
3
+ - attributes.each do |attr|
4
+ %dt
5
+ = resource_class.human_attribute_name(attr)
6
+ %dd
7
+ = resource.public_send(attr) || "none"
8
+ .btn-group
9
+ = link_to t(:back), collection_path, :class=>"btn btn-action"
10
+ = link_to t(:edit), edit_resource_path(resource), :class=>"btn btn-warning"
@@ -0,0 +1,142 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ # Wrappers are used by the form builder to generate a
4
+ # complete input. You can remove any component from the
5
+ # wrapper, change the order or even add your own to the
6
+ # stack. The options given below are used to wrap the
7
+ # whole input.
8
+ config.wrappers :default, :class => :input,
9
+ :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
10
+ ## Extensions enabled by default
11
+ # Any of these extensions can be disabled for a
12
+ # given input by passing: `f.input EXTENSION_NAME => false`.
13
+ # You can make any of these extensions optional by
14
+ # renaming `b.use` to `b.optional`.
15
+
16
+ # Determines whether to use HTML5 (:email, :url, ...)
17
+ # and required attributes
18
+ b.use :html5
19
+
20
+ # Calculates placeholders automatically from I18n
21
+ # You can also pass a string as f.input :placeholder => "Placeholder"
22
+ b.use :placeholder
23
+
24
+ ## Optional extensions
25
+ # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
26
+ # to the input. If so, they will retrieve the values from the model
27
+ # if any exists. If you want to enable the lookup for any of those
28
+ # extensions by default, you can change `b.optional` to `b.use`.
29
+
30
+ # Calculates maxlength from length validations for string inputs
31
+ b.optional :maxlength
32
+
33
+ # Calculates pattern from format validations for string inputs
34
+ b.optional :pattern
35
+
36
+ # Calculates min and max from length validations for numeric inputs
37
+ b.optional :min_max
38
+
39
+ # Calculates readonly automatically from readonly attributes
40
+ b.optional :readonly
41
+
42
+ ## Inputs
43
+ b.use :label_input
44
+ b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
45
+ b.use :error, :wrap_with => { :tag => :span, :class => :error }
46
+ end
47
+
48
+ # The default wrapper to be used by the FormBuilder.
49
+ config.default_wrapper = :default
50
+
51
+ # Define the way to render check boxes / radio buttons with labels.
52
+ # Defaults to :nested for bootstrap config.
53
+ # :inline => input + label
54
+ # :nested => label > input
55
+ config.boolean_style = :nested
56
+
57
+ # Default class for buttons
58
+ config.button_class = 'btn'
59
+
60
+ # Method used to tidy up errors. Specify any Rails Array method.
61
+ # :first lists the first message for each field.
62
+ # Use :to_sentence to list all errors for each field.
63
+ # config.error_method = :first
64
+
65
+ # Default tag used for error notification helper.
66
+ config.error_notification_tag = :div
67
+
68
+ # CSS class to add for error notification helper.
69
+ config.error_notification_class = 'alert alert-error'
70
+
71
+ # ID to add for error notification helper.
72
+ # config.error_notification_id = nil
73
+
74
+ # Series of attempts to detect a default label method for collection.
75
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
76
+
77
+ # Series of attempts to detect a default value method for collection.
78
+ # config.collection_value_methods = [ :id, :to_s ]
79
+
80
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
81
+ # config.collection_wrapper_tag = nil
82
+
83
+ # You can define the class to use on all collection wrappers. Defaulting to none.
84
+ # config.collection_wrapper_class = nil
85
+
86
+ # You can wrap each item in a collection of radio/check boxes with a tag,
87
+ # defaulting to :span. Please note that when using :boolean_style = :nested,
88
+ # SimpleForm will force this option to be a label.
89
+ # config.item_wrapper_tag = :span
90
+
91
+ # You can define a class to use in all item wrappers. Defaulting to none.
92
+ # config.item_wrapper_class = nil
93
+
94
+ # How the label text should be generated altogether with the required text.
95
+ # config.label_text = lambda { |label, required| "#{required} #{label}" }
96
+
97
+ # You can define the class to use on all labels. Default is nil.
98
+ config.label_class = 'control-label'
99
+
100
+ # You can define the class to use on all forms. Default is simple_form.
101
+ # config.form_class = :simple_form
102
+
103
+ # You can define which elements should obtain additional classes
104
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
105
+
106
+ # Whether attributes are required by default (or not). Default is true.
107
+ # config.required_by_default = true
108
+
109
+ # Tell browsers whether to use default HTML5 validations (novalidate option).
110
+ # Default is enabled.
111
+ config.browser_validations = false
112
+
113
+ # Collection of methods to detect if a file type was given.
114
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
115
+
116
+ # Custom mappings for input types. This should be a hash containing a regexp
117
+ # to match as key, and the input type that will be used when the field name
118
+ # matches the regexp as value.
119
+ # config.input_mappings = { /count/ => :integer }
120
+
121
+ # Custom wrappers for input types. This should be a hash containing an input
122
+ # type as key and the wrapper that will be used for all inputs with specified type.
123
+ # config.wrapper_mappings = { :string => :prepend }
124
+
125
+ # Default priority for time_zone inputs.
126
+ # config.time_zone_priority = nil
127
+
128
+ # Default priority for country inputs.
129
+ # config.country_priority = nil
130
+
131
+ # Default size for text inputs.
132
+ # config.default_input_size = 50
133
+
134
+ # When false, do not use translations for labels.
135
+ # config.translate_labels = true
136
+
137
+ # Automatically discover new inputs in Rails' autoload path.
138
+ # config.inputs_discovery = true
139
+
140
+ # Cache SimpleForm inputs discovery
141
+ # config.cache_discovery = !Rails.env.development?
142
+ end