biovision-courses 0.0.180221 → 0.0.180222

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef0a244be3c7edae730b4a22aa130a30a5e46d5871a077e523f888206f730a4d
4
- data.tar.gz: 5dcc1ab277316189046e8bb6f92d76f7ea25b15ac2b2fcd7b9de8f9f6b196686
3
+ metadata.gz: 1e92e5e05e40d16f33cad8c82b6b40018a4ea7498a457f63ea5a0ef67d05ccea
4
+ data.tar.gz: afd2ed14417c7b9d91500e62b6928c4e6fdad9a8b8f2c1738f484c643d0d9a89
5
5
  SHA512:
6
- metadata.gz: 6e079e7d896731c82f592a768f3c0ca054579e4fec37ff1a554d0eab2b739c273be1d45e9f9b3e295da824490f5c6835e10be1da9e237875b883862533be93c6
7
- data.tar.gz: b8c41be72cf172bfd3117f4f7a77806edc5a68ca832b5be37b4083360691d2d0ffb07a1ad53617f9eacbcd7b4b57741c62dd0675c6ba4efc95f24845b428c465
6
+ metadata.gz: 00a9075f2ba86e9224def3657c3c6a1366f865f924ef82f8f847b814d17fef3fefd625d90f9e0b875a7a8fcb231f1fe8179bfcd7699693392240f6ad5837e4de
7
+ data.tar.gz: eca8189c23cc1429890e3b57d15c3d731172aeb71a39444db1b4178e1348317d98ccb5bb65b6dd2d362c707dfc54130ba19fff493499d17ebc16d9a57080de31
@@ -0,0 +1,75 @@
1
+ .index-course-categories {
2
+ ul {
3
+ display: flex;
4
+ flex-wrap: wrap;
5
+ justify-content: space-around;
6
+ margin: 3.2rem auto;
7
+ max-width: $content-width;
8
+ padding: 0;
9
+ }
10
+
11
+ li {
12
+ border-radius: .6rem;
13
+ flex: none;
14
+ height: 16.2rem;
15
+ list-style: none;
16
+ margin: 0 .7rem 3.2rem;
17
+ overflow: hidden;
18
+ position: relative;
19
+ width: 20.6rem;
20
+ }
21
+
22
+ .image {
23
+ height: 100%;
24
+ overflow: hidden;
25
+ width: 100%;
26
+ }
27
+
28
+ img {
29
+ height: 100%;
30
+ object-fit: cover;
31
+ width: 100%;
32
+ }
33
+
34
+ a:link,
35
+ a:visited {
36
+ align-items: center;
37
+ background: rgba(0, 0, 0, .46);
38
+ bottom: 0;
39
+ color: #fff;
40
+ display: flex;
41
+ font: 700 1.8rem/1.02 $font-family-heading;
42
+ justify-content: center;
43
+ left: 0;
44
+ padding: 1.8rem .8rem .6rem;
45
+ position: absolute;
46
+ right: 0;
47
+ text-align: center;
48
+ top: 0;
49
+ }
50
+ }
51
+
52
+ .index-course-tags {
53
+ ul {
54
+ margin: 2.4rem auto;
55
+ max-width: $content-width;
56
+ padding: 0;
57
+ text-align: center;
58
+ }
59
+
60
+ li {
61
+ list-style: none;
62
+ display: inline-block;
63
+ margin: .8rem;
64
+ padding: 0;
65
+
66
+ a:link,
67
+ a:visited {
68
+ border: .1rem solid #979797;
69
+ color: #313131;
70
+ display: inline-block;
71
+ line-height: 2.6rem;
72
+ padding: 0 1.4rem;
73
+ }
74
+ }
75
+ }
@@ -1,5 +1,13 @@
1
- class CourseCategoriesController < AdminController
1
+ class CourseCategoriesController < ApplicationController
2
+ before_action :restrict_access, except: [:index, :show]
2
3
  before_action :set_entity, only: [:edit, :update, :destroy]
4
+ before_action :set_entity_for_visitor, only: [:show]
5
+
6
+ layout 'admin', except: [:index, :show]
7
+
8
+ # get /course_categories
9
+ def index
10
+ end
3
11
 
4
12
  # get /course_categories/new
5
13
  def new
@@ -21,6 +29,11 @@ class CourseCategoriesController < AdminController
21
29
  end
22
30
  end
23
31
 
32
+ # get /course_categories/:id
33
+ def show
34
+ @collection = @entity.courses.page_for_visitors(current_page)
35
+ end
36
+
24
37
  # get /course_categories/:id/edit
25
38
  def edit
26
39
  end
@@ -60,6 +73,13 @@ class CourseCategoriesController < AdminController
60
73
  end
61
74
  end
62
75
 
76
+ def set_entity_for_visitor
77
+ @entity = CourseCategory.visible.find_by(id: params[:id])
78
+ if @entity.nil?
79
+ handle_http_404('Cannot find visible course_category')
80
+ end
81
+ end
82
+
63
83
  def entity_parameters
64
84
  params.require(:course_category).permit(CourseCategory.entity_parameters)
65
85
  end
@@ -1,5 +1,13 @@
1
- class CourseTagsController < AdminController
1
+ class CourseTagsController < ApplicationController
2
+ before_action :restrict_access, except: [:index, :show]
2
3
  before_action :set_entity, only: [:edit, :update, :destroy]
4
+ before_action :set_entity_for_visitor, only: [:show]
5
+
6
+ layout 'admin', except: [:index, :show]
7
+
8
+ # get /course_tags
9
+ def index
10
+ end
3
11
 
4
12
  # get /course_tags/new
5
13
  def new
@@ -21,6 +29,11 @@ class CourseTagsController < AdminController
21
29
  end
22
30
  end
23
31
 
32
+ # get /course_tags/:id
33
+ def show
34
+ @collection = @entity.courses.page_for_visitors(current_page)
35
+ end
36
+
24
37
  # get /course_tags/:id/edit
25
38
  def edit
26
39
  end
@@ -60,6 +73,13 @@ class CourseTagsController < AdminController
60
73
  end
61
74
  end
62
75
 
76
+ def set_entity_for_visitor
77
+ @entity = CourseTag.visible.find_by(id: params[:id])
78
+ if @entity.nil?
79
+ handle_http_404('Cannot find visible course_tag')
80
+ end
81
+ end
82
+
63
83
  def entity_parameters
64
84
  params.require(:course_tag).permit(CourseTag.entity_parameters)
65
85
  end
@@ -42,6 +42,20 @@ module BiovisionCoursesHelper
42
42
  link_to(text, course_path(entity.id), options)
43
43
  end
44
44
 
45
+ # @param [CourseCategory] entity
46
+ # @param [String] text
47
+ # @param [Hash] options
48
+ def course_category_link(entity, text = entity.name, options = {})
49
+ link_to(text, course_category_path(entity.id), options)
50
+ end
51
+
52
+ # @param [CourseTag] entity
53
+ # @param [String] text
54
+ # @param [Hash] options
55
+ def course_tag_link(entity, text = entity.name, options = {})
56
+ link_to(text, course_tag_path(entity.id), options)
57
+ end
58
+
45
59
  # Course image preview for displaying in "administrative" lists
46
60
  #
47
61
  # @param [Course] entity
@@ -0,0 +1,10 @@
1
+ <div class="course-preview">
2
+ <div class="image"><%= course_image_small(entity) %></div>
3
+ <div class="info">
4
+ <div class="title"><%= course_link(entity) %></div>
5
+ <div class="lead"><%= simple_format(entity.lead) %></div>
6
+ <div class="footer">
7
+ <div class="duration"><%= entity.duration %></div>
8
+ </div>
9
+ </div>
10
+ </div>
@@ -0,0 +1,13 @@
1
+ <% content_for :meta_title, t('.title', page: current_page) %>
2
+
3
+ <article>
4
+ <h1><%= t('.heading') %></h1>
5
+
6
+ <%= paginate @collection %>
7
+ <ul>
8
+ <% @collection.each do |entity| %>
9
+ <li><%= course_link(entity) %></li>
10
+ <% end %>
11
+ </ul>
12
+ <%= paginate @collection %>
13
+ </article>
@@ -0,0 +1,17 @@
1
+ json.data @collection do |entity|
2
+ json.id entity.id
3
+ json.type entity.class.table_name
4
+ json.attributes do
5
+ json.(entity, :title, :subtitle, :lead, :duration)
6
+ end
7
+ json.meta do
8
+ unless entity.image.blank?
9
+ json.image do
10
+ json.small entity.image.small.url
11
+ json.small_2x entity.image.medium.url
12
+ end
13
+ end
14
+ json.html render(partial: 'courses/preview', formats: [:html], locals: { entity: entity } )
15
+ end
16
+ end
17
+ json.partial! 'shared/pagination', locals: { collection: @collection }
@@ -0,0 +1,15 @@
1
+ <% collection = CourseCategory.visible.for_tree %>
2
+ <% if collection.any? %>
3
+ <section class="index-course-categories">
4
+ <h2><%= t('.heading') %></h2>
5
+
6
+ <ul>
7
+ <% collection.each do |entity| %>
8
+ <li>
9
+ <div class="image"><%= course_image_small(entity) %></div>
10
+ <%= course_category_link(entity) %>
11
+ </li>
12
+ <% end %>
13
+ </ul>
14
+ </section>
15
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <% collection = CourseTag.list_for_visitors %>
2
+ <% if collection.any? %>
3
+ <section class="index-course-tags">
4
+ <h2><%= t('.heading') %></h2>
5
+
6
+ <ul>
7
+ <% collection.each do |entity| %>
8
+ <li><%= course_tag_link(entity) %></li>
9
+ <% end %>
10
+ </ul>
11
+ </section>
12
+ <% end %>
@@ -136,3 +136,13 @@ ru:
136
136
  new:
137
137
  title: "Добавление курса"
138
138
  heading: "Новый курс"
139
+ index:
140
+ title: "Все курсы, страница %{page}"
141
+ heading: "Все курсы"
142
+ index:
143
+ index:
144
+ biovision_courses:
145
+ categories:
146
+ heading: "Категории курсов"
147
+ tags:
148
+ heading: "Метки курсов"
@@ -1,6 +1,5 @@
1
1
  Rails.application.routes.draw do
2
- resources :courses
3
- resources :course_categories, :course_tags, except: [:index, :show]
2
+ resources :courses, :course_categories, :course_tags
4
3
 
5
4
  namespace :admin do
6
5
  resources :course_categories, only: [:index, :show] do
@@ -1,5 +1,5 @@
1
1
  module Biovision
2
2
  module Courses
3
- VERSION = '0.0.180221'
3
+ VERSION = '0.0.180222'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biovision-courses
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.180221
4
+ version: 0.0.180222
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Khan-Magomedov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-21 00:00:00.000000000 Z
11
+ date: 2018-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -120,7 +120,7 @@ files:
120
120
  - Rakefile
121
121
  - app/assets/config/biovision_courses_manifest.js
122
122
  - app/assets/javascripts/biovision/courses/application.js
123
- - app/assets/stylesheets/biovision/courses/application.css
123
+ - app/assets/stylesheets/biovision/courses/biovision-courses.scss
124
124
  - app/controllers/admin/course_categories_controller.rb
125
125
  - app/controllers/admin/course_tags_controller.rb
126
126
  - app/controllers/admin/courses_controller.rb
@@ -163,11 +163,16 @@ files:
163
163
  - app/views/course_tags/new.html.erb
164
164
  - app/views/course_tags/new.js.erb
165
165
  - app/views/courses/_form.html.erb
166
+ - app/views/courses/_preview.html.erb
166
167
  - app/views/courses/edit.html.erb
167
168
  - app/views/courses/edit.js.erb
168
169
  - app/views/courses/form/_wysiwyg.html.erb
170
+ - app/views/courses/index.html.erb
171
+ - app/views/courses/index.jbuilder
169
172
  - app/views/courses/new.html.erb
170
173
  - app/views/courses/new.js.erb
174
+ - app/views/index/index/biovision_courses/_categories.html.erb
175
+ - app/views/index/index/biovision_courses/_tags.html.erb
171
176
  - app/views/layouts/biovision/courses/application.html.erb
172
177
  - config/locales/courses-ru.yml
173
178
  - config/routes.rb
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */