redditor 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +27 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +8 -0
  5. data/Gemfile +23 -0
  6. data/Guardfile +24 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +16 -0
  9. data/Rakefile +23 -0
  10. data/app/assets/images/redditor/.keep +0 -0
  11. data/app/assets/images/redditor/add_photo.png +0 -0
  12. data/app/assets/images/redditor/add_photo_big.png +0 -0
  13. data/app/assets/images/redditor/add_slider.png +0 -0
  14. data/app/assets/images/redditor/add_slider_big.png +0 -0
  15. data/app/assets/images/redditor/add_txt.png +0 -0
  16. data/app/assets/images/redditor/add_txt_big.png +0 -0
  17. data/app/assets/images/redditor/add_video.png +0 -0
  18. data/app/assets/images/redditor/add_video_big.png +0 -0
  19. data/app/assets/images/redditor/destroy_block_text.png +0 -0
  20. data/app/assets/images/redditor/move_handler.png +0 -0
  21. data/app/assets/images/redditor/no_format_text.png +0 -0
  22. data/app/assets/images/redditor/trash.png +0 -0
  23. data/app/assets/javascripts/fileapi/FileAPI.exif.js +59 -0
  24. data/app/assets/javascripts/fileapi/FileAPI.flash.image.swf +0 -0
  25. data/app/assets/javascripts/fileapi/FileAPI.flash.swf +0 -0
  26. data/app/assets/javascripts/fileapi/FileAPI.id3.js +67 -0
  27. data/app/assets/javascripts/fileapi/FileAPI.min.js +73 -0
  28. data/app/assets/javascripts/fileapi/fileapi.js.coffee.erb +12 -0
  29. data/app/assets/javascripts/fileapi/tmpl.js +35 -0
  30. data/app/assets/javascripts/fileapi/uploader.coffee +139 -0
  31. data/app/assets/javascripts/jquery-ui.min.js +12 -0
  32. data/app/assets/javascripts/redditor/application.js +14 -0
  33. data/app/assets/javascripts/redditor/fileapi/FileAPI.exif.js +59 -0
  34. data/app/assets/javascripts/redditor/fileapi/FileAPI.flash.image.swf +0 -0
  35. data/app/assets/javascripts/redditor/fileapi/FileAPI.flash.swf +0 -0
  36. data/app/assets/javascripts/redditor/fileapi/FileAPI.id3.js +67 -0
  37. data/app/assets/javascripts/redditor/fileapi/FileAPI.min.js +72 -0
  38. data/app/assets/javascripts/redditor/fileapi/README.md +724 -0
  39. data/app/assets/javascripts/redditor/fileapi/config.js.coffee.erb +5 -0
  40. data/app/assets/javascripts/redditor/fileapi/crossdomain.xml +19 -0
  41. data/app/assets/javascripts/redditor/fileapi/example.userpic.html +212 -0
  42. data/app/assets/javascripts/redditor/fileapi/index.html +548 -0
  43. data/app/assets/javascripts/redditor/fileapi/mailru.js +6 -0
  44. data/app/assets/javascripts/redditor/fileapi/mailru_front.js.coffee +143 -0
  45. data/app/assets/javascripts/redditor/fileapi/tmpl.js +35 -0
  46. data/app/assets/javascripts/redditor/fileapi/uploader.coffee +139 -0
  47. data/app/assets/javascripts/redditor/redditor.coffee +148 -0
  48. data/app/assets/stylesheets/redditor/application.css.scss +47 -0
  49. data/app/assets/stylesheets/redditor/fileapi/fileapi.css.scss +174 -0
  50. data/app/assets/stylesheets/redditor/fileapi/fileapi_front.css.scss +175 -0
  51. data/app/assets/stylesheets/redditor/redditor.css.scss +108 -0
  52. data/app/controllers/redditor/admin/base_controller.rb +18 -0
  53. data/app/controllers/redditor/admin/image_blocks_controller.rb +37 -0
  54. data/app/controllers/redditor/admin/images_controller.rb +33 -0
  55. data/app/controllers/redditor/admin/pages_controller.rb +15 -0
  56. data/app/controllers/redditor/admin/slider_blocks_controller.rb +32 -0
  57. data/app/controllers/redditor/admin/text_blocks_controller.rb +31 -0
  58. data/app/controllers/redditor/admin/video_blocks_controller.rb +31 -0
  59. data/app/controllers/redditor/application_controller.rb +4 -0
  60. data/app/helpers/redditor/application_helper.rb +4 -0
  61. data/app/helpers/redditor/fileapi_helper.rb +17 -0
  62. data/app/helpers/redditor/pages_helper.rb +24 -0
  63. data/app/models/redditor/content_block.rb +24 -0
  64. data/app/models/redditor/image.rb +29 -0
  65. data/app/models/redditor/page.rb +28 -0
  66. data/app/models/redditor/slider_block.rb +17 -0
  67. data/app/models/redditor/text_block.rb +20 -0
  68. data/app/models/redditor/video_block.rb +27 -0
  69. data/app/uploaders/redditor_uploader.rb +57 -0
  70. data/app/views/layouts/redditor/application.html.erb +15 -0
  71. data/app/views/redditor/admin/pages/_content_block.haml +16 -0
  72. data/app/views/redditor/admin/pages/_fileapi.erb +199 -0
  73. data/app/views/redditor/admin/pages/_image.haml +18 -0
  74. data/app/views/redditor/admin/pages/_page.haml +13 -0
  75. data/app/views/redditor/admin/pages/_slider_block.haml +16 -0
  76. data/app/views/redditor/admin/pages/_slider_block_image.haml +3 -0
  77. data/app/views/redditor/admin/pages/_text_block.haml +5 -0
  78. data/app/views/redditor/admin/pages/_validate.haml +4 -0
  79. data/app/views/redditor/admin/pages/_video_block.haml +19 -0
  80. data/app/views/redditor/admin/pages/_wrap_dd.haml +1 -0
  81. data/app/views/redditor/admin/pages/_wrapper.haml +3 -0
  82. data/app/views/redditor/admin/pages/new.js.coffee +7 -0
  83. data/app/views/redditor/admin/pages/new.js.erb +7 -0
  84. data/app/views/redditor/admin/pages/slider_block_image.js.coffee +2 -0
  85. data/app/views/redditor/admin/pages/wrapper.js.coffee +6 -0
  86. data/app/views/redditor/pages/_page.html.haml +1 -0
  87. data/app/views/redditor/slider_blocks/_slider_block.html.haml +2 -0
  88. data/app/views/redditor/slider_blocks/_slider_block_image.html.erb +3 -0
  89. data/app/views/redditor/text_blocks/_text_block.html.haml +1 -0
  90. data/app/views/redditor/video_blocks/_video_block.html.haml +2 -0
  91. data/bin/rails +8 -0
  92. data/config/locales/redditor.en.yml +20 -0
  93. data/config/locales/redditor.ru.yml +20 -0
  94. data/config/routes.rb +17 -0
  95. data/db/migrate/20130916155124_create_redditor_images.rb +15 -0
  96. data/db/migrate/20130916155156_create_redditor_pages.rb +12 -0
  97. data/db/migrate/20130916155219_create_redditor_slider_blocks.rb +11 -0
  98. data/db/migrate/20130916155239_create_redditor_text_blocks.rb +12 -0
  99. data/db/migrate/20130916155301_create_redditor_video_blocks.rb +14 -0
  100. data/lib/generators/redditor/views/views_generator.rb +17 -0
  101. data/lib/redditor/engine.rb +12 -0
  102. data/lib/redditor/has_redditor.rb +17 -0
  103. data/lib/redditor/version.rb +3 -0
  104. data/lib/redditor.rb +9 -0
  105. data/lib/tasks/redditor_tasks.rake +4 -0
  106. data/redditor.gemspec +38 -0
  107. data/spec/dummy/.rspec +1 -0
  108. data/spec/dummy/README.rdoc +28 -0
  109. data/spec/dummy/Rakefile +6 -0
  110. data/spec/dummy/app/assets/images/.keep +0 -0
  111. data/spec/dummy/app/assets/javascripts/application.js +17 -0
  112. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  113. data/spec/dummy/app/controllers/admin/articles_controller.rb +23 -0
  114. data/spec/dummy/app/controllers/admin/base_controller.rb +6 -0
  115. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  116. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  117. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  118. data/spec/dummy/app/mailers/.keep +0 -0
  119. data/spec/dummy/app/models/.keep +0 -0
  120. data/spec/dummy/app/models/article.rb +7 -0
  121. data/spec/dummy/app/models/concerns/.keep +0 -0
  122. data/spec/dummy/app/views/admin/articles/edit.html.haml +15 -0
  123. data/spec/dummy/app/views/articles/show.html.haml +2 -0
  124. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  125. data/spec/dummy/bin/bundle +3 -0
  126. data/spec/dummy/bin/rails +4 -0
  127. data/spec/dummy/bin/rake +4 -0
  128. data/spec/dummy/config/application.rb +31 -0
  129. data/spec/dummy/config/boot.rb +5 -0
  130. data/spec/dummy/config/database.yml +25 -0
  131. data/spec/dummy/config/environment.rb +5 -0
  132. data/spec/dummy/config/environments/development.rb +29 -0
  133. data/spec/dummy/config/environments/production.rb +80 -0
  134. data/spec/dummy/config/environments/test.rb +36 -0
  135. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  136. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  137. data/spec/dummy/config/initializers/inflections.rb +16 -0
  138. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  139. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  140. data/spec/dummy/config/initializers/session_store.rb +3 -0
  141. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  142. data/spec/dummy/config/locales/en.yml +23 -0
  143. data/spec/dummy/config/routes.rb +10 -0
  144. data/spec/dummy/config.ru +4 -0
  145. data/spec/dummy/db/migrate/20130908123351_create_articles.rb +9 -0
  146. data/spec/dummy/db/schema.rb +76 -0
  147. data/spec/dummy/lib/assets/.keep +0 -0
  148. data/spec/dummy/log/.keep +0 -0
  149. data/spec/dummy/public/404.html +58 -0
  150. data/spec/dummy/public/422.html +58 -0
  151. data/spec/dummy/public/500.html +57 -0
  152. data/spec/dummy/public/favicon.ico +0 -0
  153. data/spec/factories/articles_factory.rb +27 -0
  154. data/spec/factories/redditor/images_factory.rb +9 -0
  155. data/spec/factories/redditor/pages_factory.rb +37 -0
  156. data/spec/factories/redditor/sliders_factory.rb +9 -0
  157. data/spec/factories/redditor/texts_factory.rb +5 -0
  158. data/spec/factories/redditor/videos_factories.rb +7 -0
  159. data/spec/features/text_spec.rb +52 -0
  160. data/spec/features/video_spec.rb +52 -0
  161. data/spec/fixtures/test.jpg +0 -0
  162. data/spec/generators/views_generator_spec.rb +20 -0
  163. data/spec/models/article_spec.rb +40 -0
  164. data/spec/spec_helper.rb +67 -0
  165. data/spec/views/article/show_spec.rb +22 -0
  166. metadata +480 -0
@@ -0,0 +1,139 @@
1
+ window.FU =
2
+ config:
3
+ maxFileSizeMB: 10
4
+ messages:
5
+ error: "Ошибка"
6
+ done: "Загружено"
7
+ data: ->
8
+ icon:
9
+ image: "//cdn1.iconfinder.com/data/icons/humano2/32x32/apps/synfig_icon.png"
10
+
11
+ files: []
12
+ index: 0
13
+ active: false
14
+
15
+ add: (file) ->
16
+ FU.files.push file
17
+ if /^image/.test(file.type)
18
+ FileAPI.Image(file).preview(35).rotate("auto").get (err, img) ->
19
+ FU._getEl(file, ".js-left").addClass("b-file__left_border").html img unless err
20
+
21
+ getFileById: (id) ->
22
+ i = FU.files.length
23
+ return FU.files[i] if FileAPI.uid(FU.files[i]) is id while i--
24
+
25
+ start: ->
26
+ FU._upload FU.files[FU.index] if not FU.active and (FU.active = FU.files.length > FU.index)
27
+
28
+ abort: (id) ->
29
+ file = @getFileById(id)
30
+ file.xhr.abort() if file.xhr
31
+
32
+ _getEl: (file, sel) ->
33
+ $el = $("#file-" + FileAPI.uid(file))
34
+ (if sel then $el.find(sel) else $el)
35
+
36
+ _upload: (file) ->
37
+ if file
38
+ FileAPI.upload(
39
+ url: FU.config.uploadUrl+"?authenticity_token=#{encodeURIComponent($("meta[name=\"csrf-token\"]").attr("content"))}"
40
+ data: FU.config.data()
41
+ dataType: "script"
42
+
43
+ files:
44
+ file: file
45
+
46
+ upload: ->
47
+ FU._getEl(file).addClass "b-file_upload"
48
+ FU._getEl(file, ".js-progress").css(opacity: 0).show().animate
49
+ opacity: 1
50
+ , 100
51
+
52
+ progress: (evt) ->
53
+ FU._getEl(file, ".js-bar").css "width", evt.loaded / evt.total * 100 + "%"
54
+
55
+ complete: (err, xhr) ->
56
+ setTimeout(xhr.responseText, 10)
57
+
58
+ state = (if err then "error" else "done")
59
+ FU._getEl(file).removeClass "b-file_upload"
60
+ FU._getEl(file, ".js-progress").animate
61
+ opacity: 0
62
+ , 200, ->
63
+ $(@).hide().closest("div.js-file").delay(1000).fadeOut 200, ->
64
+ $(@).remove()
65
+
66
+ FU._getEl(file, ".js-info").append ", <b class=\"b-file__" + state + "\">" + ((if err then (xhr.statusText or err) else FU.config.messages[state])) + "</b>"
67
+ FU.index++
68
+ FU.active = false
69
+ FU.start()
70
+ )
71
+
72
+ template: '<div id="file-<%=FileAPI.uid(file)%>" class="js-file b-file b-file_<%=file.type.split("/")[0]%>">
73
+ <div class="js-left b-file__left">
74
+ <img src="<%=icon[file.type.split("/")[0]]||icon.def%>" width="32" height="32" style="margin: 2px 0 0 3px"/>
75
+ </div>
76
+ <div class="b-file__right">
77
+ <div class="js-name b-file__name"><%=file.name%></div>
78
+ <div class="js-info b-file__info">Размер: <%=(file.size/FileAPI.KB).toFixed(2)%> KB</div>
79
+ <div class="js-progress b-file__bar" style="display: none">
80
+ <div class="b-progress"><div class="js-bar b-progress__bar"></div></div>
81
+ </div>
82
+ </div>
83
+ <i class="js-abort b-file__abort" title="abort">&times;</i>
84
+ </div>'
85
+
86
+
87
+ window.onFiles = (files, context) ->
88
+ $context = $(context)
89
+ if uploadUrl = $context.data("upload-url")
90
+ FU.config.uploadUrl = uploadUrl
91
+
92
+ if contentBlockId = $context.data("content-block-id")
93
+ FU.config.data = ->
94
+ REDDE.redditor.parameterizationForm $context.closest("dd")
95
+ else
96
+ FU.config.data = ->
97
+
98
+ FileAPI.each files, (file) ->
99
+ if file.size >= FU.config.maxFileSizeMB * FileAPI.MB
100
+ alert "Sorrow.\nMax size #{FU.config.maxFileSizeMB}MB"
101
+ else if file.size is undefined
102
+ $("#oooops").show()
103
+ $("#buttons-panel").hide()
104
+ else
105
+ $("#preview").append tmpl(window.FU.template,
106
+ file: file
107
+ icon: FU.icon
108
+ )
109
+ FU.add file
110
+ FU.start()
111
+
112
+ $ ->
113
+ unless FileAPI.support.cors or FileAPI.support.flash
114
+ $("<div />",
115
+ class: "alert"
116
+ html: "Увы, ваш браузер не поддерживает html5 и flash, поэтому смотреть тут нечего, а iframe не даёт всей красоты :]"
117
+ ).insertAfter "#page-header" # если загрузка не поддерживается, то выводим сообщение
118
+ $('#buttons-panel').hide()
119
+
120
+
121
+ if FileAPI.support.dnd
122
+ $('#drag-n-drop').show() #выводим текст с сообщение что работает dnd
123
+ $(document).dnd (over) ->
124
+ $('#drop-zone').toggleClass "active", over #Если кто-то перетащил файлы в браузер подсвечиваем область в которую их можно бросить
125
+ return
126
+ , ->
127
+ $('#drop-zone').dnd (over) ->
128
+ return
129
+ , (files) ->
130
+ onFiles files, this
131
+ return
132
+
133
+ $(document).on 'change', 'input.js-fileapi[type="file"]', (evt) ->
134
+ files = FileAPI.getFiles(evt)
135
+ onFiles(files, this)
136
+ FileAPI.reset(evt.currentTarget)
137
+ return
138
+
139
+ return