publinator 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,68 @@
1
+ module Publinator
2
+ class Manage::PublishableTypesController < ManageController
3
+ def index
4
+ @publishable_types = Publinator::PublishableType.all
5
+ respond_to do |format|
6
+ format.html # index.html.erb
7
+ format.json { render json: @manage_publishable_types }
8
+ end
9
+ end
10
+
11
+ def show
12
+ @manage_publishable_type = Manage::PublishableType.find(params[:id])
13
+
14
+ respond_to do |format|
15
+ format.html # show.html.erb
16
+ format.json { render json: @manage_publishable_type }
17
+ end
18
+ end
19
+
20
+ def new
21
+ @manage_publishable_type = Manage::PublishableType.new
22
+
23
+ respond_to do |format|
24
+ format.html # new.html.erb
25
+ format.json { render json: @manage_publishable_type }
26
+ end
27
+ end
28
+
29
+ def edit
30
+ @publishable_type = PublishableType.find(params[:id])
31
+ end
32
+
33
+ def create
34
+ @manage_publishable_type = Manage::PublishableType.new(params[:manage_publishable_type])
35
+ respond_to do |format|
36
+ if @manage_publishable_type.save
37
+ format.html { redirect_to manage_publishable_types_path, notice: 'Publishable type was successfully created.' }
38
+ format.json { render json: @manage_publishable_type, status: :created, location: @manage_publishable_type }
39
+ else
40
+ format.html { render action: "new" }
41
+ format.json { render json: @manage_publishable_type.errors, status: :unprocessable_entity }
42
+ end
43
+ end
44
+ end
45
+
46
+ def update
47
+ @manage_publishable_type = Publinator::PublishableType.find(params[:id])
48
+ respond_to do |format|
49
+ if @manage_publishable_type.update_attributes(params[:manage_publishable_type])
50
+ format.html { redirect_to manage_publishable_types_path, notice: 'Publishable type was successfully updated.' }
51
+ format.json { head :no_content }
52
+ else
53
+ format.html { render action: "edit" }
54
+ format.json { render json: @manage_publishable_type.errors, status: :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ def destroy
60
+ @manage_publishable_type = Publinator::PublishableType.find(params[:id])
61
+ @manage_publishable_type.destroy
62
+ respond_to do |format|
63
+ format.html { redirect_to manage_publishable_types_url }
64
+ format.json { head :no_content }
65
+ end
66
+ end
67
+ end
68
+ end
@@ -1,7 +1,7 @@
1
1
  require_dependency "publinator/application_controller"
2
2
 
3
3
  module Publinator
4
- class Manage::SectionsController < ApplicationController
4
+ class Manage::SectionsController < Publinator::ManageController
5
5
 
6
6
  before_filter :get_section, :except => [:index, :new]
7
7
 
@@ -3,11 +3,24 @@ require_dependency "publinator/application_controller"
3
3
  module Publinator
4
4
  class PublishableController < Publinator::ApplicationController
5
5
  def index
6
- @publishables = current_site.publications('published', 'updated_at desc', params["publishable_type"].singularize.capitalize)
7
- begin
8
- render "#{params[:publishable_type]}/index"
9
- rescue ActionView::MissingTemplate
10
- render "publinator/publishable/index"
6
+ @publication = Publinator::Publication.find_by_publishable_type_and_slug(params[:publishable_type].singularize.capitalize, 'index')
7
+ if @publication.nil?
8
+ logger.info "looking for publication with slug #{params[:publishable_type]}"
9
+ @publication = Publinator::Publication.find_by_slug(params[:publishable_type])
10
+ @publishable = @publication.publishable
11
+ logger.info @publication.to_yaml
12
+ begin
13
+ render "#{params[:publishable_type]}/show"
14
+ rescue ActionView::MissingTemplate
15
+ render "publinator/publishable/show"
16
+ end
17
+ else
18
+ @publishables = current_site.publications('published', 'updated_at desc', params["publishable_type"].singularize.capitalize)
19
+ begin
20
+ render "#{params[:publishable_type]}/index"
21
+ rescue ActionView::MissingTemplate
22
+ render "publinator/publishable/index"
23
+ end
11
24
  end
12
25
  end
13
26
 
@@ -0,0 +1,4 @@
1
+ module Publinator
2
+ module Manage::PublishableTypesHelper
3
+ end
4
+ end
@@ -1,6 +1,6 @@
1
1
  #module Publinator
2
2
  class Publinator::AssetItem < ActiveRecord::Base
3
- attr_accessible :asset, :assetable
3
+ attr_accessible :asset, :assetable, :asset_type
4
4
  belongs_to :assetable, :polymorphic => true
5
5
  validates_presence_of :assetable
6
6
 
@@ -1,6 +1,6 @@
1
1
  module Publinator
2
2
  class PublishableType < ActiveRecord::Base
3
- attr_accessible :name, :sluggable
3
+ attr_accessible :name, :sluggable, :layout
4
4
 
5
5
  def self.matches?(request)
6
6
  logger.info request.path_parameters
@@ -6,3 +6,8 @@
6
6
  <%= link_to pt.name.pluralize, send("manage_#{pt.name.downcase.pluralize}_path") %><br>
7
7
  <% end %>
8
8
  <% end %>
9
+
10
+ <h3>Site Settings</h3>
11
+
12
+ <%= link_to "Publishable Types", "/manage/publishable_types" %><br>
13
+
@@ -14,7 +14,7 @@
14
14
  <%= form.semantic_fields_for :asset_items do |asset_form| %>
15
15
  <%= asset_form.inputs "Asset" do %>
16
16
  <%= asset_form.input :asset_type, :as => :select, :collection => @publishable.asset_types %>
17
- <%= asset_form.input :asset_file, :as => :file %>
17
+ <%= asset_form.input :asset, :as => :file %>
18
18
  <% end %>
19
19
  <% end %>
20
20
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <h1><%= @publishable.title %></h1>
2
2
 
3
- <% @publishable.asset_types.each do |ai| %>
4
- <%= publishable_asset(@publishable, ai) %>
3
+ <% @publishable.asset_items.each do |ai| %>
4
+ <%= link_to(image_tag(ai.asset.url(:thumb)), ai.asset.url(:original), :target => "_new") %>
5
5
  <% end %>
6
6
 
7
7
  <p>
@@ -0,0 +1,19 @@
1
+ <%= semantic_form_for [:manage, @publishable_type] do |f| %>
2
+ <% if @publishable_type.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@manage_publishable_type.errors.count, "error") %> prohibited this manage_publishable_type from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @manage_publishable_type.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+
15
+ <%= f.inputs %>
16
+ <div class="actions">
17
+ <%= f.actions %>
18
+ </div>
19
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing Publishable Type</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', manage_publishable_type_path(@publishable_type) %> |
6
+ <%= link_to 'Back', manage_publishable_types_path %>
@@ -0,0 +1,22 @@
1
+ <h1>Listing manage_publishable_types</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th></th>
6
+ <th></th>
7
+ <th></th>
8
+ </tr>
9
+
10
+ <% @publishable_types.each do |publishable_type| %>
11
+ <tr>
12
+ <td><%= publishable_type.name %></td>
13
+ <td><%= link_to 'Show', manage_publishable_type_path(publishable_type) %></td>
14
+ <td><%= link_to 'Edit', edit_manage_publishable_type_path(publishable_type) %></td>
15
+ <td><%= link_to 'Destroy', manage_publishable_type_path(publishable_type), method: :delete, data: { confirm: 'Are you sure?' } %></td>
16
+ </tr>
17
+ <% end %>
18
+ </table>
19
+
20
+ <br />
21
+
22
+ <%= link_to 'New Publishable type', new_manage_publishable_type_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New manage_publishable_type</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', manage_publishable_types_path %>
@@ -0,0 +1,5 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+
4
+ <%= link_to 'Edit', edit_manage_publishable_type_path(@manage_publishable_type) %> |
5
+ <%= link_to 'Back', manage_publishable_types_path %>
data/config/routes.rb CHANGED
@@ -36,6 +36,7 @@ Publinator::Engine.routes.draw do
36
36
  resources :pages
37
37
  resources :sites
38
38
  resources :sections
39
+ resources :publishable_types
39
40
  end
40
41
 
41
42
  #constraints(Publinator::PublishableType) do
@@ -48,6 +49,12 @@ Publinator::Engine.routes.draw do
48
49
  #:publishable_type => /\A([a-zA-Z]+[a-zA-Z_]*)\z/i
49
50
  #}, :as => "publishable"
50
51
  #end
52
+ #
53
+
54
+ Publinator::PublishableType.all.each do |pt|
55
+ resources pt.name.pluralize.downcase.to_sym, :controller => "publishable", :only => [:index, :show], :publishable_type => pt.name.pluralize.downcase
56
+ end
57
+
51
58
 
52
59
  constraints(Publinator::Section) do
53
60
  match '/:section/' => "section#index", :requirements => {
@@ -64,11 +71,6 @@ Publinator::Engine.routes.draw do
64
71
  :slug => /\A([a-zA-Z]+[a-zA-Z\-_]*)\z/i
65
72
  }, :as => 'publishable'
66
73
 
67
- Publinator::PublishableType.all.each do |pt|
68
- resources pt.name.pluralize.downcase.to_sym, :controller => "publishable", :only => [:index, :show]
69
- end
70
-
71
-
72
74
  root :to => "home#index"
73
75
  match '/' => 'home#index'
74
76
 
@@ -2,7 +2,8 @@ class CreatePublinatorPublishableTypes < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :publinator_publishable_types do |t|
4
4
  t.string :name
5
- t.string :sluggable, :default => true
5
+ t.boolean :sluggable, :default => true
6
+ t.boolean :layout, :default => false
6
7
  t.timestamps
7
8
  end
8
9
  end
@@ -1,3 +1,3 @@
1
1
  module Publinator
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/lib/publinator.rb CHANGED
@@ -42,17 +42,17 @@ module Publinator
42
42
  []
43
43
  end
44
44
 
45
- def asset_file(asset_type_text)
46
- publishable_asset = get_asset_by_type(asset_type_text)
47
- publishable_asset.asset_file if publishable_asset
45
+ def asset_files(asset_type_text = nil)
46
+ return asset_items if !asset_type_text
47
+ asset_items.where(:asset_type => asset_type_text)
48
48
  end
49
49
 
50
50
  def my_slug
51
51
  publication.slug
52
52
  end
53
53
 
54
- def asset_files
55
- asset_types.collect{ |atype| asset_file(atype) }
54
+ def related_items(scope)
55
+ []
56
56
  end
57
57
 
58
58
  def editable_fields
@@ -81,14 +81,6 @@ module Publinator
81
81
  self.publication.section = section unless !section
82
82
  self.publication.default = default
83
83
  end
84
-
85
- private
86
-
87
- def get_asset_by_type(asset_type_text)
88
- all_of_asset_type = asset_items.where(:asset_type => asset_type_text)
89
- all_of_asset_type.first if all_of_asset_type && all_of_asset_type.length
90
- end
91
-
92
84
  end
93
85
  end
94
86
 
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.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -255,6 +255,7 @@ files:
255
255
  - app/controllers/publinator/home_controller.rb
256
256
  - app/controllers/publinator/manage/pages_controller.rb
257
257
  - app/controllers/publinator/manage/publishable_controller.rb
258
+ - app/controllers/publinator/manage/publishable_types_controller.rb
258
259
  - app/controllers/publinator/manage/sections_controller.rb
259
260
  - app/controllers/publinator/manage/sites_controller.rb
260
261
  - app/controllers/publinator/manage_controller.rb
@@ -262,6 +263,7 @@ files:
262
263
  - app/controllers/publinator/section_controller.rb
263
264
  - app/helpers/publinator/application_helper.rb
264
265
  - app/helpers/publinator/home_helper.rb
266
+ - app/helpers/publinator/manage/publishable_types_helper.rb
265
267
  - app/helpers/publinator/manage/sections_helper.rb
266
268
  - app/models/publinator/asset_item.rb
267
269
  - app/models/publinator/domain_name.rb
@@ -292,6 +294,11 @@ files:
292
294
  - app/views/publinator/manage/publishable/index.html.erb
293
295
  - app/views/publinator/manage/publishable/new.html.erb
294
296
  - app/views/publinator/manage/publishable/show.html.erb
297
+ - app/views/publinator/manage/publishable_types/_form.html.erb
298
+ - app/views/publinator/manage/publishable_types/edit.html.erb
299
+ - app/views/publinator/manage/publishable_types/index.html.erb
300
+ - app/views/publinator/manage/publishable_types/new.html.erb
301
+ - app/views/publinator/manage/publishable_types/show.html.erb
295
302
  - app/views/publinator/manage/sections/_form.html.erb
296
303
  - app/views/publinator/manage/sections/edit.html.erb
297
304
  - app/views/publinator/manage/sections/index.html.erb
@@ -343,7 +350,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
343
350
  version: '0'
344
351
  segments:
345
352
  - 0
346
- hash: 611779132086481296
353
+ hash: 3405866272499408844
347
354
  required_rubygems_version: !ruby/object:Gem::Requirement
348
355
  none: false
349
356
  requirements:
@@ -352,7 +359,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
352
359
  version: '0'
353
360
  segments:
354
361
  - 0
355
- hash: 611779132086481296
362
+ hash: 3405866272499408844
356
363
  requirements: []
357
364
  rubyforge_project:
358
365
  rubygems_version: 1.8.24