Skip to content

Commit

Permalink
Merge branch '364-supporters-page' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
sveredyuk committed May 25, 2017
2 parents 4a879e2 + 3dc4223 commit f977349
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/assets/javascripts/app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
initSlider();
loadFlash();
blendedImg();
initChangeImageColor();
document.removeEventListener('turbolinks:load', initApplication);
}

Expand Down
43 changes: 43 additions & 0 deletions app/assets/javascripts/app/change_img_color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
(function() {
var initChangeImageColor = function() {
var elements = document.querySelectorAll('.pk-js-changed-color-images');

for(var i = 0; i < elements.length; i++) {
var elem = elements[i];
processElement(elem);
}

function processElement(elem) {
var imgNode = elem.childNodes[0];
var canvas = document.createElement('canvas');
var imgObj = new Image();
imgObj.onload = function() {
canvas.width = imgObj.width;
canvas.height = imgObj.height;

x = canvas.getContext('2d');

x.drawImage(imgObj, 0, 0);

var img = x.getImageData(0, 0, canvas.width, canvas.height);
var pix = img.data;
var n = pix.length;

for (i = 0; i < n; i += 4) {
if (pix[i + 3] > 0) {
pix[i] = 255;
pix[i + 1] = 244;
pix[i + 2] = 218;
}
}

x.putImageData(img, 0, 0);

elem.appendChild(canvas);
}
imgObj.src = imgNode.src;
}
}

window.initChangeImageColor = initChangeImageColor;
})();
2 changes: 2 additions & 0 deletions app/assets/stylesheets/app/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

@import "pages/authentication/authentication";
@import "pages/talks-archive/talk";
@import "pages/supporters/base";
@import "pages/supporters/supporter";

@import "shared/list";
@import "shared/search";
Expand Down
Empty file.
53 changes: 53 additions & 0 deletions app/assets/stylesheets/app/pages/supporters/_supporter.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
$namespace: ".pk-supporter";

#{$namespace} {
text-decoration: none;
display: inline-block;
vertical-align: middle;
width: 200px;
height: 112px;
padding: 10px;
position: relative;
overflow: hidden;
margin: 8px 0;
img, canvas {
position: absolute;
left: 50%;
top: 50%;
transform: translate3d(-50%,-50%,0);
width: 100%;
transition: opacity .2s ease-out;
}

img {
opacity: 0;
}

canvas {
opacity: 1;
}

&:hover, &:active, &:focus {
text-decoration: none;
img {
opacity: 1;
}

canvas {
opacity: 0;
}
}
}

#{$namespace}--medium {
width: 300px;
height: 170px;
}

#{$namespace} + #{$namespace} {
margin-left: 40px;
}

#{$namespace}--medium + #{$namespace}--medium {
margin-left: 56px;
}
2 changes: 1 addition & 1 deletion app/controllers/admin/friends_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def friend
end

def friends
@friends ||= search_against(Friend).order(:name).page(params[:page])
@friends ||= search_against(Friend).includes(:group).order(:name).page(params[:page])
end

def friend_params
Expand Down
27 changes: 27 additions & 0 deletions app/controllers/supporters_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class SupportersController < ApplicationController
helper_method :course_supporters, :meetups_supporters, :inlove_partner

private

def friends_groups
@friends_groups ||= Group.friends
end

def course_supporters
@course_supporters ||= friends_groups
.find_by(name: 'Course')
.friends
.where.not(id: inlove_partner.id)
end

def meetups_supporters
@meetups_supporters ||= friends_groups
.find_by(name: 'meetups')
.friends
.where.not(id: inlove_partner.id)
end

def inlove_partner
@inlove_partner ||= Friend.find_by(name: 'OnApp')
end
end
2 changes: 2 additions & 0 deletions app/views/admin/friends/index.slim
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ table.ui.very.basic.table
thead
tr
th = t 'words.name'
th = t 'groups.singular'
th.actions colspan="2"

tbody
- friends.each do |friend|
tr
td = friend.name
td = friend&.group&.name
td.right.aligned = controls do
= admin_edit_resource_link(friend)

Expand Down
3 changes: 3 additions & 0 deletions app/views/layouts/app/_header.slim
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ header.pk-header class="#{yield(:main_header_class)}"
/li.pk-list__unit = goals_link
li.pk-list__unit.pk-header__li-list-wr
= link_to "supporters", supporters_path

li.pk-list__unit.pk-header__li-list-wr
a = "contacts"
ul.pk-header__li-list
Expand Down
14 changes: 14 additions & 0 deletions app/views/supporters/show.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.pk-container
h2 = 'Friends and supporters of pivorak community:'
- meetups_supporters.each do |meetups_supporter|
= link_to meetups_supporter.link, class: 'pk-supporter pk-supporter--medium pk-js-changed-color-images', target: '_blank'
= image_tag meetups_supporter.logo

h2 = 'Partners of Ruby Summer School:'
div
= link_to inlove_partner.link, class: 'pk-supporter pk-supporter--medium pk-js-changed-color-images', target: '_blank'
= image_tag inlove_partner.logo

- course_supporters.each do |course_supporter|
= link_to course_supporter.link, class: 'pk-supporter pk-js-changed-color-images', target: '_blank'
= image_tag course_supporter.logo
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
post :donate, on: :member
end

resource :supporters, only: %i[show]

#=== ADMIN AREA ===============================
authenticate :user, ->(u) { u.admin? } do
namespace :admin do
Expand Down

0 comments on commit f977349

Please sign in to comment.