publinator 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,7 @@ body {
18
18
  background-color: #ccc;
19
19
  margin: 0;
20
20
  padding: 0;
21
-
21
+
22
22
  #header {
23
23
  background-color: #ccc;
24
24
  margin: 0;
@@ -28,29 +28,29 @@ body {
28
28
  margin: 0;
29
29
  }
30
30
  }
31
-
31
+
32
32
  #content {
33
33
  background-color: #fff;
34
34
  margin: 0;
35
35
  padding: 2em;
36
36
  }
37
-
37
+
38
38
  #footer {
39
39
  background-color: #ccc;
40
40
  margin: 0;
41
41
  padding: 1em;
42
42
  }
43
-
43
+
44
44
  a, a:visited {
45
45
  text-decoration: none;
46
46
  }
47
-
47
+
48
48
  h1 {
49
49
  a {
50
50
  color: #000;
51
51
  }
52
52
  }
53
-
53
+
54
54
  .formtastic {
55
55
  fieldset {
56
56
  border: 0;
@@ -85,4 +85,4 @@ body {
85
85
  }
86
86
  }
87
87
  }
88
- }
88
+ }
@@ -7,7 +7,9 @@ module Publinator
7
7
  def index
8
8
  @publication = Publinator::Publication.find_by_section_id_and_slug(@section.id, 'index')
9
9
  @publishable = @publication.publishable
10
- @publishable_type = Publinator::PublishableType.find_by_name(@publication.publishable_type.classify)
10
+ if @publication.publishable_type
11
+ @publishable_type = Publinator::PublishableType.find_by_name(@publication.publishable_type.classify)
12
+ end
11
13
  begin
12
14
  render "#{params[:section]}/index"
13
15
  rescue ActionView::MissingTemplate
@@ -18,7 +20,9 @@ module Publinator
18
20
  def show
19
21
  @publication = Publinator::Publication.find(:first, :conditions => ["section_id = ? and slug = ?", @section.id, params[:id]])
20
22
  @publishable = @publication.publishable
21
- @publishable_type = Publinator::PublishableType.find_by_name(@publication.publishable_type.classify)
23
+ if @publication.publishable_type
24
+ @publishable_type = Publinator::PublishableType.find_by_name(@publication.publishable_type.classify)
25
+ end
22
26
  begin
23
27
  if @publishable_type
24
28
  render "#{@publishable_type.tableize}/show"
@@ -85,5 +85,15 @@ module Publinator
85
85
  asset = pub.asset_file(asset_type)
86
86
  image_tag asset.url if asset
87
87
  end
88
+
89
+ def asset_file_tag(object, asset_type, size = 'original', img_class = nil)
90
+ imgs = object.asset_files(asset_type)
91
+ return unless imgs && imgs.first
92
+ if img_class
93
+ image_tag(imgs.first.asset.url(size.to_sym), :class => img_class)
94
+ else
95
+ image_tag(imgs.first.asset.url(size.to_sym))
96
+ end
97
+ end
88
98
  end
89
99
  end
@@ -5,5 +5,6 @@
5
5
  validates_presence_of :assetable
6
6
 
7
7
  has_attached_file :asset
8
+ default_scope order('updated_at desc')
8
9
  end
9
10
  #end
@@ -3,7 +3,8 @@ module Publinator
3
3
  # has_paper_trail
4
4
  attr_accessible :custom_slug, :parent_id, :publication_state_id,
5
5
  :publishable_id, :publishable_type, :slug, :publish_at, :hide_in_submenu,
6
- :unpublish_at, :archive_at, :section, :default, :publishable, :site, :section_id
6
+ :unpublish_at, :archive_at, :section, :default, :publishable, :site,
7
+ :section_id, :collection_publishable_type_id, :collection_scope
7
8
  belongs_to :publishable, :polymorphic => true
8
9
  belongs_to :section, :class_name => "Publinator::Section"
9
10
  belongs_to :site
@@ -20,6 +21,13 @@ module Publinator
20
21
 
21
22
  delegate :title, :path, :menu_collection, :to => :publishable
22
23
 
24
+ def collection
25
+ return unless collection_publishable_type_id
26
+ pt = Publinator::PublishableType.find(collection_publishable_type_id)
27
+ return if !pt
28
+ pt.name.constantize.send(collection_scope.to_sym)
29
+ end
30
+
23
31
  def content
24
32
  publishable_type.constantize.find(publishable_id)
25
33
  end
@@ -12,6 +12,9 @@
12
12
  <% if @page.asset_types.length > 0 %>
13
13
  <%= form.semantic_fields_for :asset_items do |asset_form| %>
14
14
  <%= asset_form.inputs "Asset" do %>
15
+ <% if asset_form.object.asset.present? %>
16
+ <%= link_to(image_tag(asset_form.object.asset.url(:thumb)), asset_form.object.asset.url(:original), :target => "_new") %>
17
+ <% end %>
15
18
  <%= asset_form.input :asset_type, :as => :select, :collection => @page.asset_types %>
16
19
  <%= asset_form.input :asset, :as => :file %>
17
20
  <% end %>
@@ -20,6 +23,8 @@
20
23
  <%= form.semantic_fields_for :publication do |pub| %>
21
24
  <%= pub.inputs "Publication Settings" do %>
22
25
  <%= pub.input :custom_slug, :required => false %>
26
+ <%= pub.input :collection_publishable_type_id, :as => :select, :collection => Publinator::PublishableType.all, :required => false %>
27
+ <%= pub.input :collection_scope, :required => false %>
23
28
  <%= pub.input :publish_at, :as => :datetime_select, :required => false %>
24
29
  <%= pub.input :unpublish_at, :as => :datetime_select, :required => false %>
25
30
  <%= pub.input :archive_at, :as => :datetime_select, :required => false %>
@@ -12,6 +12,9 @@
12
12
  <% if @publishable.asset_types.length > 0 %>
13
13
  <%= form.semantic_fields_for :asset_items do |asset_form| %>
14
14
  <%= asset_form.inputs "Asset" do %>
15
+ <% if asset_form.object.asset.present? %>
16
+ <%= link_to(image_tag(asset_form.object.asset.url(:thumb)), asset_form.object.asset.url(:original), :target => "_new") %>
17
+ <% end %>
15
18
  <%= asset_form.input :asset_type, :as => :select, :collection => @publishable.asset_types %>
16
19
  <%= asset_form.input :asset, :as => :file %>
17
20
  <% end %>
@@ -20,6 +23,8 @@
20
23
  <%= form.semantic_fields_for :publication do |pub| %>
21
24
  <%= pub.inputs "Publication Settings" do %>
22
25
  <%= pub.input :custom_slug, :required => false %>
26
+ <%= pub.input :collection_publishable_type_id, :as => :select, :collection => Publinator::PublishableType.all, :required => false %>
27
+ <%= pub.input :collection_scope, :required => false %>
23
28
  <%= pub.input :publish_at, :as => :datetime_select, :required => false %>
24
29
  <%= pub.input :unpublish_at, :as => :datetime_select, :required => false %>
25
30
  <%= pub.input :archive_at, :as => :datetime_select, :required => false %>
@@ -3,3 +3,10 @@
3
3
  <% if @publishable.respond_to?(:publishables) %>
4
4
  <%= render :collection => @publishable.publishables, :partial => "summary" %>
5
5
  <% end %>
6
+
7
+ <% if @publication.collection %>
8
+ <div class="<%= @publication.collection.first.class.to_s.pluralize.underscore %>">
9
+ <%= render :collection => @publication.collection, :partial => "/object_blocks/#{@publication.collection.first.class.to_s.underscore}" %>
10
+ </div>
11
+ <% end %>
12
+ <div class="clear_both"></div>
@@ -0,0 +1,11 @@
1
+ class AddPublicationCollections < ActiveRecord::Migration
2
+ def up
3
+ add_column :publinator_publications, :collection_object, :string
4
+ add_column :publinator_publications, :collection_scope, :string
5
+ end
6
+
7
+ def down
8
+ remove_column :publinator_publications, :collection_object
9
+ remove_column :publinator_publications, :collection_scope
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Publinator
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -326,6 +326,7 @@ files:
326
326
  - db/migrate/20121020181204_create_publinator_asset_items.rb
327
327
  - db/migrate/20121023224457_add_show_in_nav.rb
328
328
  - db/migrate/20121024001040_add_default_position.rb
329
+ - db/migrate/20121024141632_add_publication_collections.rb
329
330
  - lib/generators/publishable/publishable_generator.rb
330
331
  - lib/generators/publishable/templates/app/models/publishable.html.erb
331
332
  - lib/generators/publishable/templates/app/models/publishable_migration.rb.erb
@@ -352,7 +353,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
352
353
  version: '0'
353
354
  segments:
354
355
  - 0
355
- hash: -2926352825039531933
356
+ hash: 4163850537072496085
356
357
  required_rubygems_version: !ruby/object:Gem::Requirement
357
358
  none: false
358
359
  requirements:
@@ -361,7 +362,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
361
362
  version: '0'
362
363
  segments:
363
364
  - 0
364
- hash: -2926352825039531933
365
+ hash: 4163850537072496085
365
366
  requirements: []
366
367
  rubyforge_project:
367
368
  rubygems_version: 1.8.24