redditor 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +27 -0
- data/.rspec +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +23 -0
- data/Guardfile +24 -0
- data/MIT-LICENSE +20 -0
- data/README.md +16 -0
- data/Rakefile +23 -0
- data/app/assets/images/redditor/.keep +0 -0
- data/app/assets/images/redditor/add_photo.png +0 -0
- data/app/assets/images/redditor/add_photo_big.png +0 -0
- data/app/assets/images/redditor/add_slider.png +0 -0
- data/app/assets/images/redditor/add_slider_big.png +0 -0
- data/app/assets/images/redditor/add_txt.png +0 -0
- data/app/assets/images/redditor/add_txt_big.png +0 -0
- data/app/assets/images/redditor/add_video.png +0 -0
- data/app/assets/images/redditor/add_video_big.png +0 -0
- data/app/assets/images/redditor/destroy_block_text.png +0 -0
- data/app/assets/images/redditor/move_handler.png +0 -0
- data/app/assets/images/redditor/no_format_text.png +0 -0
- data/app/assets/images/redditor/trash.png +0 -0
- data/app/assets/javascripts/fileapi/FileAPI.exif.js +59 -0
- data/app/assets/javascripts/fileapi/FileAPI.flash.image.swf +0 -0
- data/app/assets/javascripts/fileapi/FileAPI.flash.swf +0 -0
- data/app/assets/javascripts/fileapi/FileAPI.id3.js +67 -0
- data/app/assets/javascripts/fileapi/FileAPI.min.js +73 -0
- data/app/assets/javascripts/fileapi/fileapi.js.coffee.erb +12 -0
- data/app/assets/javascripts/fileapi/tmpl.js +35 -0
- data/app/assets/javascripts/fileapi/uploader.coffee +139 -0
- data/app/assets/javascripts/jquery-ui.min.js +12 -0
- data/app/assets/javascripts/redditor/application.js +14 -0
- data/app/assets/javascripts/redditor/fileapi/FileAPI.exif.js +59 -0
- data/app/assets/javascripts/redditor/fileapi/FileAPI.flash.image.swf +0 -0
- data/app/assets/javascripts/redditor/fileapi/FileAPI.flash.swf +0 -0
- data/app/assets/javascripts/redditor/fileapi/FileAPI.id3.js +67 -0
- data/app/assets/javascripts/redditor/fileapi/FileAPI.min.js +72 -0
- data/app/assets/javascripts/redditor/fileapi/README.md +724 -0
- data/app/assets/javascripts/redditor/fileapi/config.js.coffee.erb +5 -0
- data/app/assets/javascripts/redditor/fileapi/crossdomain.xml +19 -0
- data/app/assets/javascripts/redditor/fileapi/example.userpic.html +212 -0
- data/app/assets/javascripts/redditor/fileapi/index.html +548 -0
- data/app/assets/javascripts/redditor/fileapi/mailru.js +6 -0
- data/app/assets/javascripts/redditor/fileapi/mailru_front.js.coffee +143 -0
- data/app/assets/javascripts/redditor/fileapi/tmpl.js +35 -0
- data/app/assets/javascripts/redditor/fileapi/uploader.coffee +139 -0
- data/app/assets/javascripts/redditor/redditor.coffee +148 -0
- data/app/assets/stylesheets/redditor/application.css.scss +47 -0
- data/app/assets/stylesheets/redditor/fileapi/fileapi.css.scss +174 -0
- data/app/assets/stylesheets/redditor/fileapi/fileapi_front.css.scss +175 -0
- data/app/assets/stylesheets/redditor/redditor.css.scss +108 -0
- data/app/controllers/redditor/admin/base_controller.rb +18 -0
- data/app/controllers/redditor/admin/image_blocks_controller.rb +37 -0
- data/app/controllers/redditor/admin/images_controller.rb +33 -0
- data/app/controllers/redditor/admin/pages_controller.rb +15 -0
- data/app/controllers/redditor/admin/slider_blocks_controller.rb +32 -0
- data/app/controllers/redditor/admin/text_blocks_controller.rb +31 -0
- data/app/controllers/redditor/admin/video_blocks_controller.rb +31 -0
- data/app/controllers/redditor/application_controller.rb +4 -0
- data/app/helpers/redditor/application_helper.rb +4 -0
- data/app/helpers/redditor/fileapi_helper.rb +17 -0
- data/app/helpers/redditor/pages_helper.rb +24 -0
- data/app/models/redditor/content_block.rb +24 -0
- data/app/models/redditor/image.rb +29 -0
- data/app/models/redditor/page.rb +28 -0
- data/app/models/redditor/slider_block.rb +17 -0
- data/app/models/redditor/text_block.rb +20 -0
- data/app/models/redditor/video_block.rb +27 -0
- data/app/uploaders/redditor_uploader.rb +57 -0
- data/app/views/layouts/redditor/application.html.erb +15 -0
- data/app/views/redditor/admin/pages/_content_block.haml +16 -0
- data/app/views/redditor/admin/pages/_fileapi.erb +199 -0
- data/app/views/redditor/admin/pages/_image.haml +18 -0
- data/app/views/redditor/admin/pages/_page.haml +13 -0
- data/app/views/redditor/admin/pages/_slider_block.haml +16 -0
- data/app/views/redditor/admin/pages/_slider_block_image.haml +3 -0
- data/app/views/redditor/admin/pages/_text_block.haml +5 -0
- data/app/views/redditor/admin/pages/_validate.haml +4 -0
- data/app/views/redditor/admin/pages/_video_block.haml +19 -0
- data/app/views/redditor/admin/pages/_wrap_dd.haml +1 -0
- data/app/views/redditor/admin/pages/_wrapper.haml +3 -0
- data/app/views/redditor/admin/pages/new.js.coffee +7 -0
- data/app/views/redditor/admin/pages/new.js.erb +7 -0
- data/app/views/redditor/admin/pages/slider_block_image.js.coffee +2 -0
- data/app/views/redditor/admin/pages/wrapper.js.coffee +6 -0
- data/app/views/redditor/pages/_page.html.haml +1 -0
- data/app/views/redditor/slider_blocks/_slider_block.html.haml +2 -0
- data/app/views/redditor/slider_blocks/_slider_block_image.html.erb +3 -0
- data/app/views/redditor/text_blocks/_text_block.html.haml +1 -0
- data/app/views/redditor/video_blocks/_video_block.html.haml +2 -0
- data/bin/rails +8 -0
- data/config/locales/redditor.en.yml +20 -0
- data/config/locales/redditor.ru.yml +20 -0
- data/config/routes.rb +17 -0
- data/db/migrate/20130916155124_create_redditor_images.rb +15 -0
- data/db/migrate/20130916155156_create_redditor_pages.rb +12 -0
- data/db/migrate/20130916155219_create_redditor_slider_blocks.rb +11 -0
- data/db/migrate/20130916155239_create_redditor_text_blocks.rb +12 -0
- data/db/migrate/20130916155301_create_redditor_video_blocks.rb +14 -0
- data/lib/generators/redditor/views/views_generator.rb +17 -0
- data/lib/redditor/engine.rb +12 -0
- data/lib/redditor/has_redditor.rb +17 -0
- data/lib/redditor/version.rb +3 -0
- data/lib/redditor.rb +9 -0
- data/lib/tasks/redditor_tasks.rake +4 -0
- data/redditor.gemspec +38 -0
- data/spec/dummy/.rspec +1 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +17 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/admin/articles_controller.rb +23 -0
- data/spec/dummy/app/controllers/admin/base_controller.rb +6 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/article.rb +7 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/admin/articles/edit.html.haml +15 -0
- data/spec/dummy/app/views/articles/show.html.haml +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +31 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +10 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20130908123351_create_articles.rb +9 -0
- data/spec/dummy/db/schema.rb +76 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/articles_factory.rb +27 -0
- data/spec/factories/redditor/images_factory.rb +9 -0
- data/spec/factories/redditor/pages_factory.rb +37 -0
- data/spec/factories/redditor/sliders_factory.rb +9 -0
- data/spec/factories/redditor/texts_factory.rb +5 -0
- data/spec/factories/redditor/videos_factories.rb +7 -0
- data/spec/features/text_spec.rb +52 -0
- data/spec/features/video_spec.rb +52 -0
- data/spec/fixtures/test.jpg +0 -0
- data/spec/generators/views_generator_spec.rb +20 -0
- data/spec/models/article_spec.rb +40 -0
- data/spec/spec_helper.rb +67 -0
- data/spec/views/article/show_spec.rb +22 -0
- 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">×</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
|