redditor 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/redditor/application_helper.rb +2 -4
- data/app/models/redditor/image.rb +0 -2
- data/app/models/redditor/page.rb +6 -5
- data/app/models/redditor/slider_block.rb +2 -2
- data/app/models/redditor/text_block.rb +1 -1
- data/app/models/redditor/video_block.rb +1 -12
- data/app/validators/youtube_validator.rb +5 -0
- data/app/views/redditor/admin/_page.haml +3 -2
- data/lib/redditor/version.rb +1 -1
- data/spec/dummy/app/controllers/admin/articles_controller.rb +21 -0
- data/spec/dummy/app/views/admin/articles/edit.html.haml +2 -1
- data/spec/dummy/app/views/admin/articles/index.html.haml +8 -0
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e399c8e0938274cca6da98a2c382d4b818bf9f4d
|
4
|
+
data.tar.gz: 200d213665eec8faea1909f83b82b8c31a26a564
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9629b1b6dbc4701d51a966074e5a2e3a066c7c8a1555ee39ec306a930a2c520349fb61f16642316c596f5c8d9efbef6e9efabe5ad4ccae9e16787d88d4664766
|
7
|
+
data.tar.gz: 25a9e5ac05f6e212b2dd2c25e4a40be25741ce79b94cddcca9b7bcd4518e86a041faf58262cf6de692e4c29bae0c7b85d43ae53d6e7e9e982718db7792e1fddd
|
@@ -13,15 +13,13 @@ module Redditor
|
|
13
13
|
def redditor_form(f, &block)
|
14
14
|
id = "#{real_name(f.object)}_"
|
15
15
|
id += f.object.id.nil? ? "#{f.object.object_id}" : "#{f.object.id}"
|
16
|
-
if f.object.object_id.present?
|
17
|
-
f.object_name.sub!(/\[\d*\]/, "[#{f.object.object_id}]")
|
18
|
-
end
|
16
|
+
f.object_name.sub!(/\[\d*\]/, "[#{f.object.object_id}]") if f.object.object_id.present?
|
19
17
|
index = if f.object.object_id.present?
|
20
18
|
f.object.object_id
|
21
19
|
else
|
22
20
|
f.index
|
23
21
|
end
|
24
|
-
data = {'object-name' => f.object_name, 'object-id' => index}
|
22
|
+
data = { 'object-name' => f.object_name, 'object-id' => index }
|
25
23
|
content_tag(:div, capture(&block), class: 'redditor__form', id: id, data: data)
|
26
24
|
end
|
27
25
|
|
data/app/models/redditor/page.rb
CHANGED
@@ -5,10 +5,11 @@ module Redditor
|
|
5
5
|
self.table_name = "redditor_pages"
|
6
6
|
|
7
7
|
belongs_to :pageable, polymorphic: true, touch: true
|
8
|
-
|
9
|
-
has_many :
|
10
|
-
has_many :
|
11
|
-
has_many :
|
8
|
+
|
9
|
+
has_many :text_blocks, class_name: "::Redditor::TextBlock"
|
10
|
+
has_many :video_blocks, class_name: "::Redditor::VideoBlock"
|
11
|
+
has_many :images, as: :imageable, class_name: "::Redditor::Image"
|
12
|
+
has_many :slider_blocks, class_name: "::Redditor::SliderBlock"
|
12
13
|
|
13
14
|
accepts_nested_attributes_for :text_blocks, allow_destroy: true
|
14
15
|
accepts_nested_attributes_for :video_blocks, allow_destroy: true
|
@@ -20,7 +21,7 @@ module Redditor
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def content_blocks
|
23
|
-
(
|
24
|
+
(text_blocks + video_blocks + images + slider_blocks).sort {|x, y| x.position <=> y.position}
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -6,8 +6,8 @@ module Redditor
|
|
6
6
|
|
7
7
|
attr_accessor :object_id, :kind
|
8
8
|
|
9
|
-
belongs_to :page, class_name: "Redditor::Page", touch: true
|
10
|
-
has_many :images, as: :imageable, dependent: :destroy
|
9
|
+
belongs_to :page, class_name: "::Redditor::Page", touch: true
|
10
|
+
has_many :images, as: :imageable, dependent: :destroy, class_name: "::Redditor::Image"
|
11
11
|
accepts_nested_attributes_for :images
|
12
12
|
|
13
13
|
def self.model_name
|
@@ -1,14 +1,3 @@
|
|
1
|
-
#coding: utf-8
|
2
|
-
|
3
|
-
class YoutubeValidator < ActiveModel::EachValidator
|
4
|
-
def validate_each(record, attribute, value)
|
5
|
-
if value =~ /[^A-z0-9_-]/
|
6
|
-
record.errors[attribute] << (options[:message] || "- используются недопустимые символы")
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
1
|
module Redditor
|
13
2
|
class VideoBlock < ActiveRecord::Base
|
14
3
|
self.table_name = "redditor_video_blocks"
|
@@ -17,7 +6,7 @@ module Redditor
|
|
17
6
|
|
18
7
|
validates :youtube, length: { is: 11 }, youtube: true
|
19
8
|
|
20
|
-
belongs_to :page, class_name: "Redditor::Page", touch: true
|
9
|
+
belongs_to :page, class_name: "::Redditor::Page", touch: true
|
21
10
|
|
22
11
|
def self.model_name
|
23
12
|
ActiveModel::Name.new(self, nil, 'VideoBlock')
|
@@ -1,8 +1,9 @@
|
|
1
1
|
= f.fields_for :page, f.object.page do |p|
|
2
2
|
|
3
3
|
- unless f.object.new_record?
|
4
|
-
%dl#redditor.redditor{data: {"sort-url" => url_for(redditor.sort_admin_page_path(p.object))}}
|
5
|
-
= render partial: "redditor/admin/content_block", collection: p.object.content_blocks, locals: {p: p, page: p.object}, layout: 'redditor/admin/wrap'
|
4
|
+
%dl#redditor.redditor{ data: {"sort-url" => url_for(redditor.sort_admin_page_path(p.object)) } }
|
5
|
+
/ = render partial: "redditor/admin/content_block", collection: p.object.content_blocks, locals: { p: p, page: p.object }, layout: 'redditor/admin/wrap'
|
6
|
+
= p.object.content_blocks.to_json
|
6
7
|
|
7
8
|
%div.redditor__add-blocks
|
8
9
|
%p
|
data/lib/redditor/version.rb
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
class Admin::ArticlesController < Admin::BaseController
|
4
4
|
|
5
|
+
def index
|
6
|
+
@articles = Article.all
|
7
|
+
end
|
8
|
+
|
9
|
+
def new
|
10
|
+
@article = Article.new
|
11
|
+
render "edit"
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
@article = Article.new(article_params)
|
16
|
+
if @article.save
|
17
|
+
redirect_to [:edit, :admin, @article], notice: "Article created"
|
18
|
+
else
|
19
|
+
render "edit", alert: "Error"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
5
23
|
def edit
|
6
24
|
@article = Article.find(params[:id])
|
7
25
|
@article.build_page.save unless @article.page
|
@@ -14,6 +32,9 @@ class Admin::ArticlesController < Admin::BaseController
|
|
14
32
|
end
|
15
33
|
|
16
34
|
def destroy
|
35
|
+
@article = Article.find(params[:id])
|
36
|
+
@article.destroy
|
37
|
+
redirect_to [:admin, :articles]
|
17
38
|
end
|
18
39
|
|
19
40
|
private
|
data/spec/dummy/config/routes.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -14,7 +14,7 @@ require 'capybara/rails'
|
|
14
14
|
require 'capybara/rspec'
|
15
15
|
require 'capybara/poltergeist'
|
16
16
|
|
17
|
-
Capybara.default_wait_time = ENV['CAPYBARA_WAIT_TIME'].present? ? ENV['CAPYBARA_WAIT_TIME'].to_i :
|
17
|
+
Capybara.default_wait_time = ENV['CAPYBARA_WAIT_TIME'].present? ? ENV['CAPYBARA_WAIT_TIME'].to_i : 10
|
18
18
|
|
19
19
|
Capybara.register_driver :poltergeist do |app|
|
20
20
|
Capybara::Poltergeist::Driver.new(app, {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redditor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Bovykin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- app/models/redditor/text_block.rb
|
178
178
|
- app/models/redditor/video_block.rb
|
179
179
|
- app/uploaders/redditor_uploader.rb
|
180
|
+
- app/validators/youtube_validator.rb
|
180
181
|
- app/views/layouts/redditor/application.html.erb
|
181
182
|
- app/views/redditor/admin/_content_block.haml
|
182
183
|
- app/views/redditor/admin/_image.haml
|
@@ -245,6 +246,7 @@ files:
|
|
245
246
|
- spec/dummy/app/models/article.rb
|
246
247
|
- spec/dummy/app/models/concerns/.keep
|
247
248
|
- spec/dummy/app/views/admin/articles/edit.html.haml
|
249
|
+
- spec/dummy/app/views/admin/articles/index.html.haml
|
248
250
|
- spec/dummy/app/views/articles/show.html.haml
|
249
251
|
- spec/dummy/app/views/layouts/application.html.erb
|
250
252
|
- spec/dummy/bin/bundle
|
@@ -344,6 +346,7 @@ test_files:
|
|
344
346
|
- spec/dummy/app/models/article.rb
|
345
347
|
- spec/dummy/app/models/concerns/.keep
|
346
348
|
- spec/dummy/app/views/admin/articles/edit.html.haml
|
349
|
+
- spec/dummy/app/views/admin/articles/index.html.haml
|
347
350
|
- spec/dummy/app/views/articles/show.html.haml
|
348
351
|
- spec/dummy/app/views/layouts/application.html.erb
|
349
352
|
- spec/dummy/bin/bundle
|