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,19 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
|
3
|
+
|
4
|
+
<cross-domain-policy>
|
5
|
+
<site-control permitted-cross-domain-policies="all"/>
|
6
|
+
<allow-access-from domain="local.git" secure="false"/>
|
7
|
+
<allow-access-from domain="local.evil" secure="false"/>
|
8
|
+
<allow-access-from domain="rubaxa.org" secure="false"/>
|
9
|
+
<allow-access-from domain="*.rubaxa.org" secure="false"/>
|
10
|
+
<allow-access-from domain="github.com" secure="false"/>
|
11
|
+
<allow-access-from domain="*.github.com" secure="false"/>
|
12
|
+
<allow-access-from domain="mail.ru" secure="false"/>
|
13
|
+
<allow-access-from domain="*.mail.ru" secure="false"/>
|
14
|
+
<allow-access-from domain="imgsmail.ru" secure="false"/>
|
15
|
+
<allow-access-from domain="*.imgsmail.ru" secure="false"/>
|
16
|
+
<allow-access-from domain="img.imgsmail.ru" secure="false"/>
|
17
|
+
<allow-access-from domain="*.img.imgsmail.ru" secure="false"/>
|
18
|
+
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
|
19
|
+
</cross-domain-policy>
|
@@ -0,0 +1,212 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<!--
|
3
|
+
|
4
|
+
|
5
|
+
~~~ Это пример создания загрузки фото! ~~~
|
6
|
+
|
7
|
+
|
8
|
+
1. Скопируйте исходники себе в проект
|
9
|
+
2. Разместите crossdomain.xml на домене, куда будут грузиться файлы
|
10
|
+
3. Укажите правильный путь к флешкам, он задаётся через "staticPath"
|
11
|
+
4. ...
|
12
|
+
5. Profit!
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
-->
|
17
|
+
<html>
|
18
|
+
<head>
|
19
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
20
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
21
|
+
|
22
|
+
<meta name="viewport" content="user-scalable=no, width=400, initial-scale=0.8, maximum-scale=0.8" />
|
23
|
+
<meta name="apple-mobile-web-app-capable" content="yes" />
|
24
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="yes" />
|
25
|
+
<meta name="format-detection" content="email=no" />
|
26
|
+
<meta name="HandheldFriendly" content="true" />
|
27
|
+
|
28
|
+
<title>FileAPI :: UserPic :: example</title>
|
29
|
+
|
30
|
+
<script>
|
31
|
+
// Объект настройки
|
32
|
+
var FileAPI = {
|
33
|
+
debug: false, // режим отладки
|
34
|
+
staticPath: './' // путь до флешек
|
35
|
+
};
|
36
|
+
</script>
|
37
|
+
<script src="./FileAPI.min.js"></script>
|
38
|
+
|
39
|
+
<style>
|
40
|
+
.upload-link {
|
41
|
+
color: #36c;
|
42
|
+
display: inline-block;
|
43
|
+
*zoom: 1;
|
44
|
+
*display: inline;
|
45
|
+
overflow: hidden;
|
46
|
+
position: relative;
|
47
|
+
text-decoration: none;
|
48
|
+
background-color: #fff;
|
49
|
+
background-color: rgba(255,255,255,.85);
|
50
|
+
padding: 3px 8px;
|
51
|
+
}
|
52
|
+
.upload-link__txt {
|
53
|
+
z-index: 1;
|
54
|
+
position: relative;
|
55
|
+
border-bottom: 1px dotted #36c;
|
56
|
+
}
|
57
|
+
.upload-link:hover .upload-link__txt {
|
58
|
+
color: #f00;
|
59
|
+
border-bottom-color: #f00;
|
60
|
+
}
|
61
|
+
|
62
|
+
.upload-link__inp {
|
63
|
+
top: -10px;
|
64
|
+
right: -40px;
|
65
|
+
z-index: 2;
|
66
|
+
position: absolute;
|
67
|
+
cursor: pointer;
|
68
|
+
opacity: 0;
|
69
|
+
filter: alpha(opacity=0);
|
70
|
+
font-size: 50px;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
.upload {
|
75
|
+
width: 230px;
|
76
|
+
height: 200px;
|
77
|
+
border: 2px solid #ccc;
|
78
|
+
position: relative;
|
79
|
+
background-color: #fff;
|
80
|
+
}
|
81
|
+
.upload__preview {
|
82
|
+
-webkit-transition: opacity .3s ease;
|
83
|
+
-moz-transition: opacity .3s ease;
|
84
|
+
transition: opacity .3s ease;
|
85
|
+
}
|
86
|
+
|
87
|
+
.upload__progress {
|
88
|
+
color: #fff;
|
89
|
+
}
|
90
|
+
|
91
|
+
.upload__link,
|
92
|
+
.upload__progress {
|
93
|
+
top: 45%;
|
94
|
+
width: 100%;
|
95
|
+
position: absolute;
|
96
|
+
text-align: center;
|
97
|
+
}
|
98
|
+
|
99
|
+
.upload__progress,
|
100
|
+
.upload_active .upload__link { display: none; }
|
101
|
+
|
102
|
+
.upload_active .upload__preview { opacity: .75; }
|
103
|
+
.upload_active .upload__progress { display: block; }
|
104
|
+
</style>
|
105
|
+
</head>
|
106
|
+
<body>
|
107
|
+
|
108
|
+
<form name="userpic" class="upload">
|
109
|
+
<div id="preview" class="upload__preview"></div>
|
110
|
+
|
111
|
+
<div class="upload__progress">Uploading…</div>
|
112
|
+
|
113
|
+
<div class="upload__link">
|
114
|
+
<a class="upload-link js-fileapi-wrapper">
|
115
|
+
<span class="upload-link__txt">Browse pic</span>
|
116
|
+
<input class="upload-link__inp" name="photo" type="file" accept=".jpg,.jpeg,.gif" />
|
117
|
+
</a>
|
118
|
+
</div>
|
119
|
+
</form>
|
120
|
+
|
121
|
+
<script>
|
122
|
+
(function (){
|
123
|
+
// Ссылка на uploader
|
124
|
+
var form = document.forms.userpic;
|
125
|
+
|
126
|
+
// Ссылка на инпут, через который юзер будет выбирать файл
|
127
|
+
var input = form.photo;
|
128
|
+
|
129
|
+
// Ссылка на DOM-элемент, где будем отображать preview
|
130
|
+
var preview = document.getElementById('preview');
|
131
|
+
|
132
|
+
// Параметры предварительного просмотра
|
133
|
+
var previewOpts = {
|
134
|
+
width: 230
|
135
|
+
, height: 200
|
136
|
+
};
|
137
|
+
|
138
|
+
// Параметры загрузки
|
139
|
+
var uploadOpts = {
|
140
|
+
url: 'http://www.rubaxa.org/index.php' // куда грузить
|
141
|
+
, data: {} // дополнительный POST-параметры
|
142
|
+
, name: 'userpic' // название POST-параметра загружаемого файла
|
143
|
+
, activeClassName: 'upload_active' // класс, который будем добавлять общему контейнеру при загрузке
|
144
|
+
};
|
145
|
+
|
146
|
+
// Функция, которая будет срабатывать при выборе файла
|
147
|
+
var _onSelectFile = function (evt/**Event*/){
|
148
|
+
// Получаем выбранный файл
|
149
|
+
var file = FileAPI.getFiles(evt)[0];
|
150
|
+
|
151
|
+
if( file ){
|
152
|
+
// Строим preview для изображений
|
153
|
+
_createPreview(file);
|
154
|
+
|
155
|
+
// Загружаем файл на сервер
|
156
|
+
_uploadFile(file);
|
157
|
+
}
|
158
|
+
};
|
159
|
+
|
160
|
+
// Функция создающая preview для изображения
|
161
|
+
var _createPreview = function (file/**File*/){
|
162
|
+
FileAPI.Image(file)
|
163
|
+
.preview(previewOpts.width, previewOpts.height)
|
164
|
+
.get(function (err, image){
|
165
|
+
// Если не было ошибок, то вставляем изображение
|
166
|
+
if( !err ){
|
167
|
+
// Отчищаем контейнер от текущего изображения
|
168
|
+
preview.innerHTML = '';
|
169
|
+
|
170
|
+
// Вставляем новое
|
171
|
+
preview.appendChild(image);
|
172
|
+
}
|
173
|
+
})
|
174
|
+
;
|
175
|
+
};
|
176
|
+
|
177
|
+
// Функция загрузки файла на сервер
|
178
|
+
var _uploadFile = function (file){
|
179
|
+
// Подготавливаем опции для загрузки
|
180
|
+
var opts = FileAPI.extend(uploadOpts, {
|
181
|
+
files: {},
|
182
|
+
|
183
|
+
// событие "начало загрузки"
|
184
|
+
upload: function (){
|
185
|
+
form.className += ' '+uploadOpts.activeClassName;
|
186
|
+
},
|
187
|
+
|
188
|
+
// событие "конец загрузки"
|
189
|
+
complete: function (err, xhr){
|
190
|
+
form.className = (' '+form.className+' ').replace(' '+uploadOpts.activeClassName+' ', ' ');
|
191
|
+
|
192
|
+
if( err ){
|
193
|
+
alert('Увы, произошла ошибка сервера.');
|
194
|
+
} else {
|
195
|
+
// всё успешно загрузилось
|
196
|
+
}
|
197
|
+
}
|
198
|
+
});
|
199
|
+
|
200
|
+
// Добавляем файл
|
201
|
+
opts.files[opts.name] = file;
|
202
|
+
|
203
|
+
// Загружаем на сервер
|
204
|
+
FileAPI.upload(opts);
|
205
|
+
};
|
206
|
+
|
207
|
+
// Подписываемся на событие "change", оно будет срабатывать при выборе файла
|
208
|
+
FileAPI.event.on(input, "change", _onSelectFile);
|
209
|
+
})();
|
210
|
+
</script>
|
211
|
+
</body>
|
212
|
+
</html>
|