kuhsaft 1.2.9 → 1.2.10

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.
@@ -0,0 +1,25 @@
1
+ module Kuhsaft
2
+ class AssetBrick < Brick
3
+ attr_accessible :caption, :link_style, :asset
4
+
5
+ mount_uploader :asset, Kuhsaft::AssetBrickAssetUploader
6
+
7
+ validates :caption, :asset, :presence => true
8
+
9
+ def self.styles
10
+ %w(pdf word excel button)
11
+ end
12
+
13
+ def to_style_class
14
+ [super, link_style.presence].join(' ')
15
+ end
16
+
17
+ def collect_fulltext
18
+ [super, caption].join(' ')
19
+ end
20
+
21
+ def user_can_add_childs?
22
+ false
23
+ end
24
+ end
25
+ end
@@ -1,6 +1,6 @@
1
1
  module Kuhsaft
2
2
  class LinkBrick < Brick
3
- attr_accessible :href, :caption, :link_style
3
+ attr_accessible :href, :caption, :link_style, :open_in_new_window
4
4
 
5
5
  validates :href, :caption, :presence => true
6
6
 
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ class Kuhsaft::AssetBrickAssetUploader < CarrierWave::Uploader::Base
4
+
5
+ # Include RMagick or ImageScience support:
6
+ # include CarrierWave::MiniMagick
7
+ #include CarrierWave::ImageScience
8
+
9
+ # Choose what kind of storage to use for this uploader:
10
+ storage :file
11
+ # storage :s3
12
+
13
+ # Override the directory where uploaded files will be stored.
14
+ # This is a sensible default for uploaders that are meant to be mounted:
15
+ def store_dir
16
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
17
+ end
18
+
19
+ # Provide a default URL as a default if there hasn't been a file uploaded:
20
+ # def default_url
21
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
22
+ # end
23
+
24
+ # Process files as they are uploaded:
25
+ # process :scale => [200, 300]
26
+ #
27
+ # def scale(width, height)
28
+ # # do something
29
+ # end
30
+
31
+ # Add a white list of extensions which are allowed to be uploaded.
32
+ # For images you might use something like this:
33
+ def extension_white_list
34
+ %w(pdf doc docx xls xlsx ppt pptx)
35
+ end
36
+
37
+ # Override the filename of the uploaded files:
38
+ # def filename
39
+ # "something.jpg" if original_filename
40
+ # end
41
+
42
+ end
@@ -0,0 +1,2 @@
1
+ %div{ :class => asset_brick.to_style_class }
2
+ = link_to asset_brick.caption, asset_brick.asset.url, :target => '_blank'
@@ -0,0 +1,7 @@
1
+ = form.input :caption, :as => :string, :input_html => { :class => 'span6' }
2
+ = form.input :asset
3
+ - if brick.asset.present?
4
+ .countrol-group
5
+ %label
6
+ = link_to File.basename(brick.asset.url), brick.asset.url
7
+ = form.input :link_style, :collection => Kuhsaft::AssetBrick.styles
@@ -1,3 +1,2 @@
1
1
  %div{ :class => link_brick.to_style_class }
2
- %a{ :href => link_brick.href }
3
- = link_brick.caption
2
+ = link_to link_brick.caption, link_brick.href, :target => link_brick.open_in_new_window? ? '_blank' : ''
@@ -1,3 +1,4 @@
1
1
  = form.input :href, :as => :string, :input_html => { :class => 'span6' }
2
2
  = form.input :caption, :as => :string, :input_html => { :class => 'span6' }
3
+ = form.input :open_in_new_window
3
4
  = form.input :link_style, :collection => Kuhsaft::LinkBrick.styles
@@ -0,0 +1,9 @@
1
+ de:
2
+ activerecord:
3
+ models:
4
+ kuhsaft/asset_brick: 'Datei'
5
+ attributes:
6
+ kuhsaft/asset_brick:
7
+ caption: 'Anzeigetext'
8
+ link_style: 'Stil'
9
+ asset: 'Datei'
@@ -7,3 +7,4 @@ de:
7
7
  caption: 'Linktext'
8
8
  href: 'Link'
9
9
  link_style: 'Stil'
10
+ open_in_new_window: 'In neuem Fenster öffnen?'
@@ -7,3 +7,8 @@ de:
7
7
  saved: 'Gespeichert! ✔'
8
8
  confirm: 'Wirklich löschen?'
9
9
  empty: 'Hier ist noch nichts.'
10
+
11
+ image_bricks:
12
+ image_brick:
13
+ edit:
14
+ image_preview: 'Vorschau'
@@ -0,0 +1,6 @@
1
+ class AddAdditionalFieldsToKuhsaftBricks < ActiveRecord::Migration
2
+ def change
3
+ add_column :kuhsaft_bricks, :asset, :string
4
+ add_column :kuhsaft_bricks, :open_in_new_window, :boolean
5
+ end
6
+ end
@@ -10,3 +10,4 @@ Kuhsaft::BrickType.create(:class_name => 'Kuhsaft::SliderBrick', :group => 'elem
10
10
  Kuhsaft::BrickType.create(:class_name => 'Kuhsaft::ImageBrick', :group => 'elements')
11
11
  Kuhsaft::BrickType.create(:class_name => 'Kuhsaft::PlaceholderBrick', :group => 'elements')
12
12
  Kuhsaft::BrickType.create(:class_name => 'Kuhsaft::AnchorBrick', :group => 'elements')
13
+ Kuhsaft::BrickType.create(:class_name => 'Kuhsaft::AssetBrick', :group => 'elements')
@@ -1,3 +1,3 @@
1
1
  module Kuhsaft
2
- VERSION = "1.2.9"
2
+ VERSION = "1.2.10"
3
3
  end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Kuhsaft::AssetBrick do
4
+
5
+ let :asset_brick do
6
+ Kuhsaft::AssetBrick.new
7
+ end
8
+
9
+ describe '#valid' do
10
+ before do
11
+ asset_brick.valid?
12
+ end
13
+
14
+ context 'without a #caption' do
15
+ it 'has an error' do
16
+ asset_brick.should have(1).error_on(:caption)
17
+ end
18
+ end
19
+ end
20
+
21
+ describe '#bricks' do
22
+ it 'can not have childs' do
23
+ asset_brick.should_not respond_to(:bricks)
24
+ end
25
+ end
26
+
27
+ describe '.styles' do
28
+ it 'returns the available link styles' do
29
+ Kuhsaft::AssetBrick.styles.should == %w(pdf word excel button)
30
+ end
31
+ end
32
+
33
+ describe '#to_style_class' do
34
+ it 'includes the link style' do
35
+ asset_brick.stub(:link_style).and_return('pdf')
36
+ asset_brick.to_style_class.should == 'kuhsaft-asset-brick pdf'
37
+ end
38
+ end
39
+
40
+ describe '#user_can_add_childs?' do
41
+ it 'returns false' do
42
+ asset_brick.user_can_add_childs?.should be_false
43
+ end
44
+ end
45
+ end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuhsaft
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.2.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Immanuel Häussermann
9
9
  - Felipe Kaufmann
10
10
  - Phil Schilter
11
+ - Donat Baier
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2013-03-06 00:00:00.000000000 Z
15
+ date: 2013-03-08 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: rspec
@@ -328,6 +329,7 @@ files:
328
329
  - app/models/kuhsaft/accordion_item_brick.rb
329
330
  - app/models/kuhsaft/anchor_brick.rb
330
331
  - app/models/kuhsaft/asset.rb
332
+ - app/models/kuhsaft/asset_brick.rb
331
333
  - app/models/kuhsaft/brick.rb
332
334
  - app/models/kuhsaft/brick_type.rb
333
335
  - app/models/kuhsaft/brick_type_filter.rb
@@ -345,6 +347,7 @@ files:
345
347
  - app/models/kuhsaft/text_brick.rb
346
348
  - app/models/kuhsaft/two_column_brick.rb
347
349
  - app/models/kuhsaft/video_brick.rb
350
+ - app/uploaders/kuhsaft/asset_brick_asset_uploader.rb
348
351
  - app/uploaders/kuhsaft/asset_uploader.rb
349
352
  - app/uploaders/kuhsaft/image_brick_image_uploader.rb
350
353
  - app/views/kuhsaft/accordion_bricks/_accordion_brick.html.haml
@@ -353,6 +356,8 @@ files:
353
356
  - app/views/kuhsaft/accordion_item_bricks/accordion_item_brick/_edit.html.haml
354
357
  - app/views/kuhsaft/anchor_bricks/_anchor_brick.html.haml
355
358
  - app/views/kuhsaft/anchor_bricks/anchor_brick/_edit.html.haml
359
+ - app/views/kuhsaft/asset_bricks/_asset_brick.html.haml
360
+ - app/views/kuhsaft/asset_bricks/asset_brick/_edit.html.haml
356
361
  - app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml
357
362
  - app/views/kuhsaft/cms/admin/_content_language_switch.html.haml
358
363
  - app/views/kuhsaft/cms/admin/_empty_state.html.haml
@@ -401,6 +406,7 @@ files:
401
406
  - config/locales/models/kuhsaft/accordion_brick/de.yml
402
407
  - config/locales/models/kuhsaft/accordion_item_brick/de.yml
403
408
  - config/locales/models/kuhsaft/anchor_brick/de.yml
409
+ - config/locales/models/kuhsaft/asset_brick/de.yml
404
410
  - config/locales/models/kuhsaft/column_brick/de.yml
405
411
  - config/locales/models/kuhsaft/image_brick/de.yml
406
412
  - config/locales/models/kuhsaft/image_size/de.yml
@@ -423,10 +429,11 @@ files:
423
429
  - db/migrate/02_create_kuhsaft_bricks.rb
424
430
  - db/migrate/03_create_kuhsaft_brick_types.rb
425
431
  - db/migrate/04_create_kuhsaft_assets.rb
432
+ - db/migrate/05_remove_cms_admin.rb
426
433
  - db/migrate/06_add_template_name_to_kuhsaft_bricks.rb
427
434
  - db/migrate/07_add_default_value_to_brick_type_enabled.rb
428
- - db/migrate/20130206141601_remove_cms_admin.rb
429
- - db/migrate/8_add_display_styles_to_bricks.rb
435
+ - db/migrate/08_add_display_styles_to_bricks.rb
436
+ - db/migrate/09_add_additional_fields_to_kuhsaft_bricks.rb
430
437
  - db/seeds.rb
431
438
  - lib/generators/kuhsaft/assets/install_generator.rb
432
439
  - lib/generators/kuhsaft/translations/add_generator.rb
@@ -487,6 +494,7 @@ files:
487
494
  - spec/models/accordion_brick_spec.rb
488
495
  - spec/models/accordion_item_brick_spec.rb
489
496
  - spec/models/anchor_brick_spec.rb
497
+ - spec/models/asset_brick_spec.rb
490
498
  - spec/models/asset_spec.rb
491
499
  - spec/models/brick_spec.rb
492
500
  - spec/models/brick_type_filter_spec.rb
@@ -517,7 +525,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
517
525
  version: '0'
518
526
  segments:
519
527
  - 0
520
- hash: -4300874740520236236
528
+ hash: 2082020547520561498
521
529
  required_rubygems_version: !ruby/object:Gem::Requirement
522
530
  none: false
523
531
  requirements:
@@ -526,7 +534,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
526
534
  version: '0'
527
535
  segments:
528
536
  - 0
529
- hash: -4300874740520236236
537
+ hash: 2082020547520561498
530
538
  requirements: []
531
539
  rubyforge_project: kuhsaft
532
540
  rubygems_version: 1.8.24
@@ -576,6 +584,7 @@ test_files:
576
584
  - spec/models/accordion_brick_spec.rb
577
585
  - spec/models/accordion_item_brick_spec.rb
578
586
  - spec/models/anchor_brick_spec.rb
587
+ - spec/models/asset_brick_spec.rb
579
588
  - spec/models/asset_spec.rb
580
589
  - spec/models/brick_spec.rb
581
590
  - spec/models/brick_type_filter_spec.rb