typus 3.1.0.rc3 → 3.1.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ Bundler::GemHelper.install_tasks
3
3
 
4
4
  require 'rubygems'
5
5
  require 'rake/testtask'
6
- require 'rake/rdoctask'
6
+ require 'rdoc/task'
7
7
 
8
8
  task :default => :test
9
9
 
@@ -0,0 +1,17 @@
1
+ <% content_for :javascripts do %>
2
+ <%= javascript_include_tag '/vendor/ckeditor/ckeditor' %>
3
+ <% end %>
4
+
5
+ <%
6
+ custom = { :rows => @resource.typus_options_for(:form_rows), :class => "rich_text" }
7
+ options = options.merge!(custom)
8
+ %>
9
+
10
+ <input type="hidden"
11
+ id="pageListJSON"
12
+ value="[<%= Page.all.map { |p| "['#{p.to_label}', '/pages/#{p.permalink}']" }.join(", ") %>]">
13
+
14
+ <li id="<%= attribute %>">
15
+ <%= form.label attribute, label_text %>
16
+ <%= form.text_area attribute, options %>
17
+ </li>
@@ -0,0 +1,12 @@
1
+ <%
2
+ unless @item.new_record?
3
+ label_text << " <small>"
4
+ label_text << link_to(Typus::I18n.t("Preview"), send("#{@item.class.model_name.downcase}_path",@item.to_param), :target => "_blank")
5
+ label_text << "</small>"
6
+ end
7
+ %>
8
+
9
+ <li id="<%= attribute %>">
10
+ <%= form.label attribute, raw(label_text) %>
11
+ <%= form.text_field attribute, options %>
12
+ </li>
@@ -26,8 +26,12 @@ module Typus
26
26
  autoload :ActsAs, "typus/controller/acts_as"
27
27
  autoload :Associations, "typus/controller/associations"
28
28
  autoload :Autocomplete, "typus/controller/autocomplete"
29
+ autoload :FeaturedImage, "typus/controller/featured_image"
29
30
  autoload :Filters, "typus/controller/filters"
30
31
  autoload :Format, "typus/controller/format"
32
+ autoload :Headless, "typus/controller/headless"
33
+ autoload :Multisite, "typus/controller/multisite"
34
+ autoload :Trash, "typus/controller/trash"
31
35
  end
32
36
 
33
37
  module Authentication
@@ -0,0 +1,24 @@
1
+ module Typus
2
+ module Controller
3
+ module FeaturedImage
4
+
5
+ def set_featured_image
6
+ attachment = Attachment.find(params[:id])
7
+
8
+ item = params[:resource].constantize.unscoped.find(params[:resource_id])
9
+ item.set_featured_image(attachment.id)
10
+
11
+ options = { :controller => params[:resource].tableize, :action => 'edit', :id => item.id }
12
+ redirect_to options, :notice => Typus::I18n.t("Featured image set")
13
+ end
14
+
15
+ def remove_featured_image
16
+ item = @resource.unscoped.find(params[:id])
17
+ item.try(:remove_featured_image)
18
+ options = { :action => 'edit', :id => item.id }
19
+ redirect_to options, :notice => Typus::I18n.t("Featured image removed")
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,28 @@
1
+ module Typus
2
+ module Controller
3
+ module Headless
4
+
5
+ def self.included(base)
6
+ base.before_filter :set_resources_action_for_headless_on_index, :only => [:index]
7
+ base.before_filter :set_resources_action_for_headless, :only => [:new, :create, :edit, :show]
8
+ base.layout :set_headless_layout
9
+ end
10
+
11
+ def set_resources_action_for_headless_on_index
12
+ add_resources_action("Add new", {:action => "new"}, {})
13
+ end
14
+ private :set_resources_action_for_headless_on_index
15
+
16
+ def set_resources_action_for_headless
17
+ add_resources_action("Back to list", {:action => 'index', :id => nil}, {})
18
+ end
19
+ private :set_resources_action_for_headless
20
+
21
+ def set_headless_layout
22
+ params[:layout] || "admin/base"
23
+ end
24
+ private :set_headless_layout
25
+
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ module Typus
2
+ module Controller
3
+ module Multisite
4
+
5
+ def set_context
6
+ @resource = admin_user.site.send(@object_name.pluralize)
7
+ end
8
+ private :set_context
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,54 @@
1
+ module Typus
2
+ module Controller
3
+ module Trash
4
+
5
+ def self.included(base)
6
+ base.before_filter :set_predefined_filter_for_trash, :only => [:index, :trash]
7
+ end
8
+
9
+ def set_predefined_filter_for_trash
10
+ add_predefined_filter("Trash", "trash", "deleted")
11
+ end
12
+ private :set_predefined_filter_for_trash
13
+
14
+ def trash
15
+ set_deleted
16
+
17
+ get_objects
18
+
19
+ respond_to do |format|
20
+ format.html do
21
+ # Actions by resource.
22
+ add_resource_action('Restore', {:action => 'restore'}, {:confirm => Typus::I18n.t("Restore %{resource}?", :resource => @resource.model_name.human)})
23
+ add_resource_action('Delete Permanently', {:action => 'wipe'}, {:confirm => Typus::I18n.t("Delete Permanently %{resource}?", :resource => @resource.model_name.human)})
24
+ # Generate and render.
25
+ generate_html
26
+ render 'index'
27
+ end
28
+ @resource.typus_export_formats.each { |f| format.send(f) { send("generate_#{f}") } }
29
+ end
30
+ end
31
+
32
+ def restore
33
+ set_deleted
34
+ @resource.find(params[:id]).restore
35
+ redirect_to :back, :notice => Typus::I18n.t("%{resource} recovered from trash.", :resource => @resource.name)
36
+ rescue ActiveRecord::RecordNotFound
37
+ redirect_to :back, :notice => Typus::I18n.t("%{resource} can't be recovered from trash.", :resource => @resource.name)
38
+ end
39
+
40
+ def wipe
41
+ set_deleted
42
+ item = @resource.find(params[:id])
43
+ item.disable_trash { item.destroy }
44
+ redirect_to :back, :notice => Typus::I18n.t("%{resource} has been successfully removed from trash.", :resource => @resource.name)
45
+ end
46
+
47
+ def set_deleted
48
+ @resource = @resource.deleted
49
+ end
50
+ private :set_deleted
51
+
52
+ end
53
+ end
54
+ end
@@ -1,3 +1,3 @@
1
1
  module Typus
2
- VERSION = "3.1.0.rc3"
2
+ VERSION = "3.1.0.rc4"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: typus
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 3.1.0.rc3
5
+ version: 3.1.0.rc4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Francesc Esplugas
@@ -242,8 +242,10 @@ files:
242
242
  - app/views/admin/templates/_profile_sidebar.html.erb
243
243
  - app/views/admin/templates/_relate_form.html.erb
244
244
  - app/views/admin/templates/_relate_form_with_autocomplete.html.erb
245
+ - app/views/admin/templates/_rich_text.html.erb
245
246
  - app/views/admin/templates/_selector.html.erb
246
247
  - app/views/admin/templates/_string.html.erb
248
+ - app/views/admin/templates/_string_with_preview.html.erb
247
249
  - app/views/admin/templates/_text.html.erb
248
250
  - app/views/admin/templates/_time.html.erb
249
251
  - app/views/admin/templates/_tree.html.erb
@@ -307,8 +309,12 @@ files:
307
309
  - lib/typus/controller/acts_as.rb
308
310
  - lib/typus/controller/associations.rb
309
311
  - lib/typus/controller/autocomplete.rb
312
+ - lib/typus/controller/featured_image.rb
310
313
  - lib/typus/controller/filters.rb
311
314
  - lib/typus/controller/format.rb
315
+ - lib/typus/controller/headless.rb
316
+ - lib/typus/controller/multisite.rb
317
+ - lib/typus/controller/trash.rb
312
318
  - lib/typus/engine.rb
313
319
  - lib/typus/i18n.rb
314
320
  - lib/typus/orm/active_record.rb