scrivito_column_widget 0.1.0
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 +7 -0
- data/README.md +13 -0
- data/Rakefile +35 -0
- data/app/assets/images/widgets/scrivito_column_widget.png +0 -0
- data/app/models/column_widget.rb +87 -0
- data/app/views/column_widget/details.html.erb +8 -0
- data/app/views/column_widget/show.html.erb +7 -0
- data/app/views/column_widget/thumbnail.html.erb +1 -0
- data/lib/scrivito_column_widget/engine.rb +5 -0
- data/lib/scrivito_column_widget/version.rb +3 -0
- data/lib/scrivito_column_widget.rb +4 -0
- data/lib/tasks/scrivito_column_widget_tasks.rake +4 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 50eab486e310bd568a3eeb22f3cd8c88ecb44513
|
4
|
+
data.tar.gz: a40af686008106d10a3a4cc7efef603b31ab9f84
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9871f672a79910640e75fa911df259b59be79a18c2bcb6451db022eb10aeb9da7df2249aab53b6dce942fc363d7873adc44cac5dd47f8e87db1208afceabe2c4
|
7
|
+
data.tar.gz: a2728aa7973b96b24f193dcce2b918a95fb0495f6ca08cc4d96f35bd6e8c81bad06ff6e03d84c608317efd7cbdd6b4bbdda0eb20df96ff779963f8c732a6d6ea
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
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 = 'ScrivitoColumnWidget'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
load 'rails/tasks/statistics.rake'
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
require 'bundler/gem_tasks'
|
24
|
+
|
25
|
+
require 'rake/testtask'
|
26
|
+
|
27
|
+
Rake::TestTask.new(:test) do |t|
|
28
|
+
t.libs << 'lib'
|
29
|
+
t.libs << 'test'
|
30
|
+
t.pattern = 'test/**/*_test.rb'
|
31
|
+
t.verbose = false
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
task default: :test
|
Binary file
|
@@ -0,0 +1,87 @@
|
|
1
|
+
class ColumnWidget < Widget
|
2
|
+
|
3
|
+
attribute :column1, :widgetlist
|
4
|
+
attribute :column2, :widgetlist
|
5
|
+
attribute :column3, :widgetlist
|
6
|
+
attribute :column4, :widgetlist
|
7
|
+
attribute :column5, :widgetlist
|
8
|
+
attribute :column6, :widgetlist
|
9
|
+
attribute :column1_width, :enum, values: ("0".."12").to_a, default: "4"
|
10
|
+
attribute :column2_width, :enum, values: ("0".."12").to_a, default: "4"
|
11
|
+
attribute :column3_width, :enum, values: ("0".."12").to_a, default: "4"
|
12
|
+
attribute :column4_width, :enum, values: ("0".."12").to_a, default: "0"
|
13
|
+
attribute :column5_width, :enum, values: ("0".."12").to_a, default: "0"
|
14
|
+
attribute :column6_width, :enum, values: ("0".."12").to_a, default: "0"
|
15
|
+
|
16
|
+
class Column
|
17
|
+
def initialize(widget:, width:, widget_list_attr_name:)
|
18
|
+
@widget = widget
|
19
|
+
@widget_list_attr_name = widget_list_attr_name
|
20
|
+
@width = width
|
21
|
+
if @width < 1 && widget_list.present?
|
22
|
+
@width = 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_reader :widget_list_attr_name
|
27
|
+
attr_reader :width
|
28
|
+
|
29
|
+
def widget_list
|
30
|
+
@widget.send(@widget_list_attr_name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def empty?
|
34
|
+
width < 1 && widget_list.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
def with_changed_width_by(change_by)
|
38
|
+
with_width(width + change_by)
|
39
|
+
end
|
40
|
+
|
41
|
+
def with_width(new_width)
|
42
|
+
self.class.new({
|
43
|
+
widget: @widget,
|
44
|
+
width: new_width,
|
45
|
+
widget_list_attr_name: widget_list_attr_name,
|
46
|
+
})
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def columns
|
51
|
+
cols = 6.downto(1).map do |number|
|
52
|
+
Column.new({
|
53
|
+
widget: self,
|
54
|
+
width: send("column#{number}_width").to_i,
|
55
|
+
widget_list_attr_name: "column#{number}",
|
56
|
+
})
|
57
|
+
end.drop_while(&:empty?)
|
58
|
+
while cols.sum(&:width) > 12
|
59
|
+
decreased = false
|
60
|
+
cols = cols.map do |column|
|
61
|
+
if !decreased && column.width > 1
|
62
|
+
decreased = true
|
63
|
+
column.with_changed_width_by(-1)
|
64
|
+
else
|
65
|
+
column
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
if (total_width = cols.sum(&:width)) < 12
|
70
|
+
cols = [cols.first.with_changed_width_by(12 - total_width)] + cols[1..-1]
|
71
|
+
end
|
72
|
+
cols.reverse
|
73
|
+
end
|
74
|
+
|
75
|
+
def text_extract
|
76
|
+
[column1, column2, column3, column4, column5, column6].map {|c| c.map(&:text_extract)}
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.description_for_editor
|
80
|
+
"Columns"
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.info_text_for_thumbnail
|
84
|
+
"Display content in 1-6 columns with adjustable widths"
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%= scrivito_details_for("Widths for columns") do %>
|
2
|
+
<%= scrivito_tag(:div, widget, :column1_width) %>
|
3
|
+
<%= scrivito_tag(:div, widget, :column2_width) %>
|
4
|
+
<%= scrivito_tag(:div, widget, :column3_width) %>
|
5
|
+
<%= scrivito_tag(:div, widget, :column4_width) %>
|
6
|
+
<%= scrivito_tag(:div, widget, :column5_width) %>
|
7
|
+
<%= scrivito_tag(:div, widget, :column6_width) %>
|
8
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= scrivito_thumbnail image_tag("scrivito_column_widget/thumbnail_column_widget.png") %>
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scrivito_column_widget
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scrivito
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: scrivito
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Scrivito Column Widget.
|
28
|
+
email:
|
29
|
+
- support@scrivito.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- app/assets/images/widgets/scrivito_column_widget.png
|
37
|
+
- app/models/column_widget.rb
|
38
|
+
- app/views/column_widget/details.html.erb
|
39
|
+
- app/views/column_widget/show.html.erb
|
40
|
+
- app/views/column_widget/thumbnail.html.erb
|
41
|
+
- lib/scrivito_column_widget.rb
|
42
|
+
- lib/scrivito_column_widget/engine.rb
|
43
|
+
- lib/scrivito_column_widget/version.rb
|
44
|
+
- lib/tasks/scrivito_column_widget_tasks.rake
|
45
|
+
homepage: https://www.scrivito.com
|
46
|
+
licenses:
|
47
|
+
- LGPL-3.0
|
48
|
+
metadata: {}
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 2.5.1
|
66
|
+
signing_key:
|
67
|
+
specification_version: 4
|
68
|
+
summary: Scrivito Column Widget.
|
69
|
+
test_files: []
|