Skip to content

Commit 5c28d01

Browse files
committed
Fixed carousel
1 parent 61d26ff commit 5c28d01

File tree

10 files changed

+208
-70
lines changed

10 files changed

+208
-70
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ RUN mkdir /confy
1313
WORKDIR /confy
1414
COPY Gemfile /confy/Gemfile
1515
COPY Gemfile.lock /confy/Gemfile.lock
16+
1617
RUN bundle install
1718
COPY . /confy

Gemfile

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,39 @@ group :development, :test do
2424
end
2525

2626
group :development do
27-
gem "bullet"
28-
gem "rack-mini-profiler"
29-
gem "web-console", ">= 3.3.0"
30-
31-
gem "listen", "~> 3.1.5"
32-
gem "better_errors"
33-
gem "binding_of_caller"
34-
gem "spring"
35-
gem "spring-watcher-listen", "~> 2.0.0"
36-
37-
gem "rubocop-rails_config"
27+
# Performance
28+
gem 'bullet', '~> 5.9'
29+
gem 'rack-mini-profiler', '~> 1.0'
30+
31+
# Errors
32+
gem 'better_errors', '~> 2.5'
33+
gem 'web-console', '~> 3.7'
34+
35+
gem 'binding_of_caller', '~> 0.8'
36+
gem 'listen', '~> 3.1'
37+
gem 'spring', '~> 2.0'
38+
gem 'spring-watcher-listen', '~> 2.0'
39+
40+
# Linters
41+
gem 'annotate', '~> 2.7'
42+
gem 'ordinare', '~> 0.4'
43+
gem 'rubocop-rails_config', '~> 0.5'
44+
45+
# Gemfile health
46+
gem 'pessimize', '~> 0.4'
3847
end
3948

4049
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
4150
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
4251
gem "responders"
4352
gem "activestorage-validator"
53+
54+
# Utils
55+
gem 'discard', '~> 1.1'
56+
gem 'pagy', '~> 3.3'
4457
gem "simple_form"
4558
gem "aws-sdk"
4659
gem "bcrypt"
60+
4761
# Levenshtein Distance Analyzer
4862
gem 'edits'

Gemfile.lock

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ GEM
4444
i18n (>= 0.7, < 2)
4545
minitest (~> 5.1)
4646
tzinfo (~> 1.1)
47+
annotate (2.7.5)
48+
activerecord (>= 3.2, < 7.0)
49+
rake (>= 10.4, < 13.0)
4750
arel (9.0.0)
4851
ast (2.4.0)
4952
aws-eventstream (1.0.1)
@@ -750,6 +753,8 @@ GEM
750753
concurrent-ruby (1.1.5)
751754
crass (1.0.4)
752755
debug_inspector (0.0.3)
756+
discard (1.1.0)
757+
activerecord (>= 4.2, < 7)
753758
edits (0.2.1)
754759
erubi (1.8.0)
755760
execjs (2.7.0)
@@ -758,7 +763,7 @@ GEM
758763
activesupport (>= 4.2.0)
759764
i18n (1.6.0)
760765
concurrent-ruby (~> 1.0)
761-
jaro_winkler (1.5.2)
766+
jaro_winkler (1.5.3)
762767
jbuilder (2.8.0)
763768
activesupport (>= 4.2.0)
764769
multi_json (>= 1.2)
@@ -784,11 +789,15 @@ GEM
784789
nio4r (2.3.1)
785790
nokogiri (1.10.1)
786791
mini_portile2 (~> 2.4.0)
787-
parallel (1.14.0)
788-
parser (2.6.0.0)
792+
ordinare (0.4.0)
793+
pagy (3.4.1)
794+
parallel (1.17.0)
795+
parser (2.6.3.0)
789796
ast (~> 2.4.0)
797+
pessimize (0.4.0)
798+
bundler
799+
trollop
790800
pg (1.1.4)
791-
psych (3.1.0)
792801
puma (3.12.0)
793802
rack (2.0.6)
794803
rack-mini-profiler (1.0.2)
@@ -831,18 +840,24 @@ GEM
831840
railties (>= 4.2.0, < 6.0)
832841
rollbar (2.18.2)
833842
multi_json
834-
rubocop (0.66.0)
843+
rubocop (0.73.0)
835844
jaro_winkler (~> 1.5.1)
836845
parallel (~> 1.10)
837-
parser (>= 2.5, != 2.5.1.1)
838-
psych (>= 3.1.0)
846+
parser (>= 2.6)
839847
rainbow (>= 2.2.2, < 4.0)
840848
ruby-progressbar (~> 1.7)
841-
unicode-display_width (>= 1.4.0, < 1.6)
842-
rubocop-rails_config (0.4.4)
849+
unicode-display_width (>= 1.4.0, < 1.7)
850+
rubocop-performance (1.4.0)
851+
rubocop (>= 0.71.0)
852+
rubocop-rails (2.2.1)
853+
rack (>= 1.1)
854+
rubocop (>= 0.72.0)
855+
rubocop-rails_config (0.6.2)
843856
railties (>= 3.0)
844-
rubocop (~> 0.58)
845-
ruby-progressbar (1.10.0)
857+
rubocop (~> 0.70)
858+
rubocop-performance (~> 1.3)
859+
rubocop-rails (~> 2.0)
860+
ruby-progressbar (1.10.1)
846861
ruby_dep (1.5.0)
847862
sass (3.7.2)
848863
sass-listen (~> 4.0.0)
@@ -874,14 +889,15 @@ GEM
874889
thor (0.20.3)
875890
thread_safe (0.3.6)
876891
tilt (2.0.9)
892+
trollop (2.9.9)
877893
turbolinks (5.2.0)
878894
turbolinks-source (~> 5.2)
879895
turbolinks-source (5.2.0)
880896
tzinfo (1.2.5)
881897
thread_safe (~> 0.1)
882898
uglifier (4.1.20)
883899
execjs (>= 0.3.0, < 3)
884-
unicode-display_width (1.5.0)
900+
unicode-display_width (1.6.0)
885901
uniform_notifier (1.12.1)
886902
web-console (3.7.0)
887903
actionview (>= 5.0)
@@ -901,32 +917,37 @@ PLATFORMS
901917

902918
DEPENDENCIES
903919
activestorage-validator
920+
annotate (~> 2.7)
904921
aws-sdk
905922
bcrypt
906-
better_errors
907-
binding_of_caller
923+
better_errors (~> 2.5)
924+
binding_of_caller (~> 0.8)
908925
bootsnap (>= 1.1.0)
909-
bullet
926+
bullet (~> 5.9)
910927
byebug
928+
discard (~> 1.1)
911929
edits
912930
jbuilder (~> 2.5)
913-
listen (~> 3.1.5)
931+
listen (~> 3.1)
932+
ordinare (~> 0.4)
933+
pagy (~> 3.3)
934+
pessimize (~> 0.4)
914935
pg (>= 0.18, < 2.0)
915936
puma (~> 3.11)
916-
rack-mini-profiler
937+
rack-mini-profiler (~> 1.0)
917938
rails (~> 5.2.2)
918939
responders
919940
rollbar
920-
rubocop-rails_config
941+
rubocop-rails_config (~> 0.5)
921942
sass-rails (~> 5.0)
922943
simple_form
923-
spring
924-
spring-watcher-listen (~> 2.0.0)
944+
spring (~> 2.0)
945+
spring-watcher-listen (~> 2.0)
925946
sqlite3 (~> 1.3.6)
926947
turbolinks (~> 5)
927948
tzinfo-data
928949
uglifier (>= 1.3.0)
929-
web-console (>= 3.3.0)
950+
web-console (~> 3.7)
930951
webpacker
931952

932953
RUBY VERSION

Makefile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1+
console:
2+
docker-compose run web rails console
3+
4+
build:
5+
docker-compose run web bundle
6+
docker-compose build
7+
8+
mine:
9+
sudo chown -R $(USER):$(USER) .
10+
111
start:
212
rm -f tmp/pids/server.pid
313
docker-compose up -d
414

5-
from_scratch:
6-
docker-compose run web rake db:setup db:seed
7-
815
stop:
916
docker-compose down
1017
rm -f tmp/pids/server.pid
1118

12-
rebuild:
13-
docker-compose build
14-
1519
rubocop:
16-
docker-compose run web rubocop -a
20+
docker-compose run web bundle exec rubocop --auto-correct
1721

1822
routes:
1923
docker-compose run web rake routes
2024

21-
console:
22-
docker-compose run web rails console
23-
2425
logs:
2526
docker-compose logs -tf
2627

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
function Carousel(settings){
2+
'use strict';
3+
settings = settings || {};
4+
this.carousel = settings.element || document.querySelector(settings.carousel || '.carousel');
5+
6+
this.slides = this.carousel.querySelectorAll('ul li');
7+
this.delay = settings.delay || 2.5;
8+
this.autoplay = settings.autoplay === undefined ? true : settings.autoplay;
9+
10+
this.slides_total = this.slides.length;
11+
this.current_slide = -1;
12+
13+
if (this.autoplay) {
14+
this.play();
15+
}
16+
}
17+
18+
Carousel.prototype.next = function (is_interval_call) {
19+
'use strict';
20+
for (var s = 0; s < this.slides.length; s += 1) {
21+
this.slides[s].style.display = 'none';
22+
}
23+
this.current_slide = (this.current_slide + 1) % this.slides.length;
24+
this.slides[this.current_slide].style.display = 'block';
25+
if (this.autoplay && this.interval && !is_interval_call) {
26+
var that = this;
27+
clearInterval(this.interval);
28+
this.interval = setTimeout(function () {
29+
that.play();
30+
}, this.delay * 1000);
31+
}
32+
};
33+
34+
Carousel.prototype.prev = function () {
35+
'use strict';
36+
for (var s = 0; s < this.slides.length; s += 1) {
37+
this.slides[s].style.display = 'none';
38+
}
39+
this.current_slide = Math.abs(this.current_slide - 1 + this.slides.length) % this.slides.length;
40+
this.slides[this.current_slide].style.display = 'block';
41+
if (this.autoplay && this.interval) {
42+
var that = this;
43+
clearInterval(this.interval);
44+
this.interval = setTimeout(function () {
45+
that.play();
46+
}, this.delay * 1000);
47+
}
48+
};
49+
50+
Carousel.prototype.play = function () {
51+
'use strict';
52+
this.next(true);
53+
var that = this;
54+
this.autoplay = true;
55+
this.interval = setTimeout(function () {
56+
that.play();
57+
}, this.delay * 1000);
58+
};
59+
60+
Carousel.prototype.stop = function () {
61+
'use strict';
62+
if (this.interval) {
63+
this.autoplay = false;
64+
clearInterval(this.interval);
65+
}
66+
};

app/controllers/api/v1/talks_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def show
1515
{
1616
slug: speaker.slug,
1717
name: speaker.name,
18+
avatar_url: speaker.avatar.attachment ? url_for(speaker.avatar.attachment) : "http://confy-assets.wecode.io/speakers/generic-speaker.png",
1819
}
1920
end,
2021
conference: {

app/javascript/components/Conference.vue

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,21 @@
5656
</div>
5757
<aside class="meta">
5858
<header class="speaker-mini" id="carousel-1">
59-
<ul>
60-
<li style="display: block;" v-for="speaker in talk.speakers" :key="speaker.slug">
61-
<div class="avathar small">
62-
<router-link :to="{ name: 'Speaker', params: { slug: speaker.slug } }">
63-
<img
64-
:alt="speaker.name"
65-
:src="speaker.avatar_url"
66-
:title="speaker.name"
67-
>
68-
</router-link>
69-
</div>
70-
</li>
71-
</ul>
59+
<div class="carousel">
60+
<ul>
61+
<li style="display: block;" v-for="speaker in talk.speakers" :key="speaker.slug">
62+
<div class="avathar small">
63+
<router-link :to="{ name: 'Speaker', params: { slug: speaker.slug } }">
64+
<img
65+
:alt="speaker.name"
66+
:src="speaker.avatar_url"
67+
:title="speaker.name"
68+
>
69+
</router-link>
70+
</div>
71+
</li>
72+
</ul>
73+
</div>
7274
<div class="info">
7375
<p class="name" v-for="speaker in talk.speakers" :key="speaker.slug">
7476
<router-link
@@ -101,6 +103,15 @@ export default {
101103
var slug = this.$route.params.slug;
102104
axios.get("/api/v1/conferences/" + slug).then(response => {
103105
this.conference = response.data;
106+
setTimeout(function(){
107+
document.querySelectorAll(".carousel").forEach(element => {
108+
new Carousel({
109+
element: element,
110+
delay: 2.5,
111+
autoplay: true
112+
})
113+
});
114+
}, 500);
104115
});
105116
}
106117
};

0 commit comments

Comments
 (0)