c80_contest 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/MIT-LICENSE +20 -0
- data/README.md +32 -0
- data/README.rdoc +3 -0
- data/Rakefile +23 -0
- data/app/admin/c80_contest/bids.rb +28 -0
- data/app/assets/images/c80_contest/.keep +0 -0
- data/app/assets/images/loading-sm.gif +0 -0
- data/app/assets/images/loading.gif +0 -0
- data/app/assets/javascripts/c80_contest/frontend/ajax_bid_form.js +157 -0
- data/app/assets/javascripts/c80_contest.js.coffee +2 -0
- data/app/assets/javascripts/lib/fileinput/fileinput.js +3833 -0
- data/app/assets/javascripts/lib/fileinput/themes/explorer/theme.js +58 -0
- data/app/assets/javascripts/lib/fileinput/themes/fa/theme.js +45 -0
- data/app/assets/javascripts/lib/fileinput/themes/gly/theme.js +45 -0
- data/app/assets/stylesheets/c80_contest/backend/bid_page.scss +22 -0
- data/app/assets/stylesheets/c80_contest/frontend/foo.scss +0 -0
- data/app/assets/stylesheets/c80_contest.scss +3 -0
- data/app/assets/stylesheets/c80_contest_active_admin.scss +2 -0
- data/app/assets/stylesheets/lib/fileinput/fileinput.scss +481 -0
- data/app/assets/stylesheets/lib/fileinput/themes/explorer/theme.scss +211 -0
- data/app/controllers/c80_contest/application_controller.rb +5 -0
- data/app/controllers/c80_contest/bid_controller.rb +26 -0
- data/app/controllers/c80_contest/site_controller.rb +13 -0
- data/app/helpers/c80_contest/application_helper.rb +26 -0
- data/app/models/c80_contest/bid.rb +17 -0
- data/app/models/c80_contest/setting.rb +53 -0
- data/app/uploaders/c80_contest/bid_photo_uploader.rb +32 -0
- data/app/views/c80_contest/bid/make_bid.js.erb +4 -0
- data/app/views/c80_contest/shared/_bid_form.html.erb +65 -0
- data/app/views/c80_contest/shared/_ok_message.html.erb +16 -0
- data/app/views/c80_contest/site/give_me_form.js.erb +4 -0
- data/app/views/layouts/c80_contest/application.html.erb +14 -0
- data/bin/console +14 -0
- data/bin/rails +12 -0
- data/bin/setup +8 -0
- data/c80_contest.gemspec +46 -0
- data/config/routes.rb +4 -0
- data/create_base.rb +25 -0
- data/db/migrate/20170510124400_create_c80_contest_bids.rb +12 -0
- data/db/migrate/20170511145501_create_c80_contest_settings.rb +19 -0
- data/db/seeds/c80_contest_fill_settings.rb +22 -0
- data/lib/c80_contest/engine.rb +20 -0
- data/lib/c80_contest/version.rb +3 -0
- data/lib/c80_contest.rb +8 -0
- data/lib/tasks/c80_contest_tasks.rake +4 -0
- metadata +335 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 37ec190a34b844e42cfeafee62ab0d88e3b73617
|
4
|
+
data.tar.gz: 421a35c9f17885da1f6d193b4d3b276418a53fd3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1798ce875d29f544941336bcf2ed976d5fad978bd7e8dab13f90f3657b926bcbc3e064f175af1bbb9d236acf75db272386e562eff5e18a22fb819e84bd6bdcfc
|
7
|
+
data.tar.gz: 9dad4584a8b24168c0f29b23a4d563886d365e89d3909355fa736ea3c3e0a0a1bc8c10cdf424990d61585ec6e4b3c0d3e759bcfbe764c8959be95ab83060d670
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
c80_contest
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.3.3
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at c080609a@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 C80609A
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/c80_contest.svg)](http://badge.fury.io/rb/c80_contest)
|
2
|
+
[![Build Status](https://travis-ci.org/c080609a/c80_contest.svg?branch=master)](https://travis-ci.org/c080609a/c80_contest)
|
3
|
+
|
4
|
+
# C80Contest
|
5
|
+
|
6
|
+
Добавляет на сайт функционал для проведения конкурса типа "пришли фотографию чека - участвуй в конкурсе по розыгрышу 500 литров бензина".
|
7
|
+
Содержит:
|
8
|
+
|
9
|
+
* форму отправки: фото чека, поля для ввода имени и телефона
|
10
|
+
* страницу в ActiveAdmin
|
11
|
+
* виджет типа "слайдер-карусель" на ActiveAdmin dashboard
|
12
|
+
|
13
|
+
## Dependencies
|
14
|
+
|
15
|
+
* rails (`::Rails::Engine`)
|
16
|
+
* activeadmin
|
17
|
+
* bootstrap
|
18
|
+
* bootstrap/modal
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Add this line to your application's Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'c80_contest'
|
26
|
+
```
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
$ bundle
|
31
|
+
|
32
|
+
## Usage
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'C80Contest'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
ActiveAdmin.register C80Contest::Bid, :as => 'Bid' do
|
2
|
+
|
3
|
+
if ActiveRecord::Base.connection.table_exists?('c80_contest_settings')
|
4
|
+
menu :parent => C80Contest::Setting.first.admin_label_menu,
|
5
|
+
:label => C80Contest::Setting.first.admin_label_menu if C80Contest::Setting.first.present?
|
6
|
+
end
|
7
|
+
|
8
|
+
config.sort_order = 'created_at_desc'
|
9
|
+
|
10
|
+
filter :title
|
11
|
+
filter :phone
|
12
|
+
filter :created_at
|
13
|
+
|
14
|
+
index do
|
15
|
+
id_column
|
16
|
+
column :created_at
|
17
|
+
column :title
|
18
|
+
column :phone
|
19
|
+
column :photo do |bid|
|
20
|
+
if bid.photo.present?
|
21
|
+
link_to image_tag(bid.photo.thumb.url), bid.photo.url
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
actions
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
File without changes
|
Binary file
|
Binary file
|
@@ -0,0 +1,157 @@
|
|
1
|
+
// Содержит функцию, которая запрашивает
|
2
|
+
// html форму с сервера, предварительно
|
3
|
+
// показывая прелоадер.
|
4
|
+
//
|
5
|
+
// Код иницализируется и начинает своё исполнение,
|
6
|
+
// если на странице есть кто-то с class='c80_contest_invoking_btn'
|
7
|
+
|
8
|
+
var bidForm;
|
9
|
+
var $c80ContestInvokingBtns;
|
10
|
+
var okMessage;
|
11
|
+
|
12
|
+
$(function () {
|
13
|
+
|
14
|
+
$c80ContestInvokingBtns = $('.c80_contest_invoking_btn');
|
15
|
+
|
16
|
+
if ($c80ContestInvokingBtns.length > 0) {
|
17
|
+
|
18
|
+
var loading = (function () {
|
19
|
+
|
20
|
+
var _$lo;
|
21
|
+
|
22
|
+
var _fInit = function () {
|
23
|
+
_$lo = $('<div id="lo"></div>');
|
24
|
+
};
|
25
|
+
|
26
|
+
var fShow = function ($clickedButton) {
|
27
|
+
|
28
|
+
_$lo.appendTo($('body'));
|
29
|
+
|
30
|
+
var top = $clickedButton.offset().top;
|
31
|
+
var left = $clickedButton.offset().left;
|
32
|
+
left -= _$lo.width() + 10;
|
33
|
+
top = top + $clickedButton.height()/2 - _$lo.height()/2;
|
34
|
+
|
35
|
+
_$lo.css("top",top+"px");
|
36
|
+
_$lo.css("left",left+"px");
|
37
|
+
};
|
38
|
+
|
39
|
+
var fHide = function () {
|
40
|
+
_$lo.addClass('invis');
|
41
|
+
setTimeout(function () {
|
42
|
+
_$lo.remove();
|
43
|
+
_$lo.removeClass('invis');
|
44
|
+
}, 1000);
|
45
|
+
};
|
46
|
+
|
47
|
+
_fInit();
|
48
|
+
|
49
|
+
return {
|
50
|
+
show:fShow,
|
51
|
+
hide:fHide
|
52
|
+
}
|
53
|
+
|
54
|
+
})();
|
55
|
+
|
56
|
+
bidForm = (function () {
|
57
|
+
|
58
|
+
var _markInvalidateInProgress = false;
|
59
|
+
var _markWasPasted = false;
|
60
|
+
var __$f;
|
61
|
+
|
62
|
+
var init = function () {
|
63
|
+
$c80ContestInvokingBtns.click(function (e) {
|
64
|
+
var $t = $(this);
|
65
|
+
e.preventDefault();
|
66
|
+
_fGetOrderForm($t);
|
67
|
+
loading.show($t);
|
68
|
+
});
|
69
|
+
};
|
70
|
+
|
71
|
+
//noinspection JSUnusedLocalSymbols
|
72
|
+
var _fGetOrderForm = function ($clickedButton) {
|
73
|
+
if (!_markInvalidateInProgress) {
|
74
|
+
_markInvalidateInProgress = true;
|
75
|
+
|
76
|
+
if (!_markWasPasted) {
|
77
|
+
|
78
|
+
$.ajax({
|
79
|
+
url: '/give_me_bid_form',
|
80
|
+
data:{
|
81
|
+
|
82
|
+
},
|
83
|
+
type: 'POST',
|
84
|
+
dataType: 'script'
|
85
|
+
}).done(function (data, result) {
|
86
|
+
if (result == "success") {
|
87
|
+
_markWasPasted = true;
|
88
|
+
_markInvalidateInProgress = false;
|
89
|
+
}
|
90
|
+
});
|
91
|
+
}
|
92
|
+
}
|
93
|
+
};
|
94
|
+
|
95
|
+
var fShowForm = function (html_str) {
|
96
|
+
|
97
|
+
var $cc = $('body');
|
98
|
+
$cc.append($(html_str));
|
99
|
+
|
100
|
+
__$f = $('#bid_form');
|
101
|
+
__$f.on('hidden.bs.modal', __fRemoveForm);
|
102
|
+
|
103
|
+
var $form = $("form#form_bid");
|
104
|
+
$form.bind("ajax:error", function (event, data, status, xhr) {
|
105
|
+
$form.render_form_errors($.parseJSON(data.responseText));
|
106
|
+
});
|
107
|
+
|
108
|
+
setTimeout(function () {
|
109
|
+
$("#bid_photo").fileinput();
|
110
|
+
__$f.modal();
|
111
|
+
loading.hide();
|
112
|
+
},1000);
|
113
|
+
|
114
|
+
/*console.log("<this.afterShowForm>" + this.afterShowForm);
|
115
|
+
if (this.afterShowForm) {
|
116
|
+
setTimeout(this.afterShowForm,200);
|
117
|
+
}*/
|
118
|
+
|
119
|
+
};
|
120
|
+
|
121
|
+
var fHideForm = function () {
|
122
|
+
__$f.modal('hide');
|
123
|
+
};
|
124
|
+
|
125
|
+
var __fRemoveForm = function () {
|
126
|
+
__$f.remove();
|
127
|
+
_markWasPasted = false;
|
128
|
+
};
|
129
|
+
|
130
|
+
return {
|
131
|
+
init: init,
|
132
|
+
show: fShowForm,
|
133
|
+
hide: fHideForm
|
134
|
+
}
|
135
|
+
|
136
|
+
})();
|
137
|
+
|
138
|
+
okMessage = (function () {
|
139
|
+
|
140
|
+
var fShow = function () {
|
141
|
+
var $form = $("#bid_ok");
|
142
|
+
$form.modal();
|
143
|
+
$form.on('hidden.bs.modal', function () {
|
144
|
+
$form.remove();
|
145
|
+
});
|
146
|
+
};
|
147
|
+
|
148
|
+
return {
|
149
|
+
show:fShow
|
150
|
+
}
|
151
|
+
|
152
|
+
})();
|
153
|
+
|
154
|
+
bidForm.init();
|
155
|
+
}
|
156
|
+
|
157
|
+
});
|